Reputation: 3828
two parts....
PART 1 - I want to redirect any request to a directory that DOES NOT exist... to a it's new location... AND and file that does not exist - to it's new location.
so: myDomain.com/myFolder (which no longer exists) gets redirected to myDomain.com/newLocation/myFolder
and / or
myDomain.com/myFolder.htm (which does NOT exist) gets redirected to myDomain.com/newlocation/myFolder
this is close...
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^myFolder http://myDomain.com/newLocation/myFolder
But I don't necessarily want to TYPE every questionable folder name, I'd prefer to have the 'newLocation" directory checked before the request fails...on any request, not just things i explicitly name
PART 2 Can someone explain the symbols used in the htaccess - or point me to a list... example:
RewriteCond %{REQUEST_URI} ^/$ Rewriterule ^(.*)$ %{REQUEST_URI}/
I look at that and I know there are meanings t0 ^/$ etc - smacks of RegEx (not familiar) or this
RewriteCond %{REQUEST_FILENAME} !-f (what's the !-f mean ????)
RewriteCond %{REQUEST_FILENAME} !-d (what's the !-d mean ????)
RewriteRule (.*) index.php?_var=$1 [L] ( the $1 means ...)
I want to understand the symbols and the syntax...
Upvotes: 2
Views: 412
Reputation: 785481
Options +FollowSymLinks -MultiViews
RewriteEngine on
# if requested URI is not a file and not a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# externally redirect to /newLocation/{URI}
RewriteRule ^ /newLocation%{REQUEST_URI} [L,R=301]
Upvotes: 1