Reputation: 7117
On my webserver I would like to redirect all visits to specific file with two exceptions. If the URI is mydomain.com/Folder1
or mydomain/Folder2
(and anything behind that) they should work normally. I tried with:
RewriteCond %{REQUEST_URI} !=www.mydomain.com/Folder1.* | www.mydomain.com/Folder2.*
RewriteRule ^.*$ www.mydomain.com/error.php [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/?$ /index.php?path=$1 [NC,L,QSA]
But this rule does not work. Can someone please have a look on it?
Upvotes: 1
Views: 223
Reputation: 785128
You can't match domain name using REQUEST_URI
variable. You can use this rule instead:
RewriteCond %{THE_REQUEST} !\s/+(error\.php|Folder1|Folder2) [NC]
RewriteRule ^ /error.php [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/?$ /index.php?path=$1 [L,QSA]
Make sure to clear your browser cache before you test this.
Upvotes: 2