I need,
in .htaccess
, redirect all behind domain, but even with more slashes and with slash or no slash at the end, but with one exception.
For example
example.com/all/sites/should/redirect/to/one/file/
example.com/all/sites/should/redirect/to/one/file
should go to
example.com/bye.php
but
example.com/exception
should work, no redirect.
I tried this.
# Turn rewriting on
Options +FollowSymLinks
RewriteEngine On
# Redirect all requests to bye.php
RewriteCond %{REQUEST_URI} !=/bye.php
RewriteCond %{REQUEST_URI} !.*\.png$ [NC]
RewriteCond %{REQUEST_URI} !.*\.jpg$ [NC]
RewriteCond %{REQUEST_URI} !.*\.css$ [NC]
RewriteCond %{REQUEST_URI} !.*\.gif$ [NC]
RewriteCond %{REQUEST_URI} !^/exception
RewriteRule .* /bye.php
RewriteEngine On
RewriteBase /
RewriteRule ^exception exception.php [QSA,L]
# Slash rules
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R]
It works, but seems only for 1 slash.
example.com/one-slash
When I enter this
example.com/more/slashes
it is not working, it is redirecting here.
example.com/bye.php/slashes/