Forum Moderators: phranque
I need to redirect ALL pages on a site except ONE URL.
So if a request comes in for /test.html I want to do nothing and serve the page as requested, if ANY OTHER request comes in, I want to redirect to example.com
I tried:
RedirectMatch!(/test\.html) http://www.example.com
But this does nothing for either pages called /test.html or for the other pages.
Thanks for any help.
Bill
RewriteEngine On
RewriteCond %{REQUEST_URI}!^/test\.html$
RewriteRule (.*) [anotherdomain.com$1...] [R=301,L]
I believe that's it there.
PS: make sure to add a space between URI} and!^/
the system takes them out for some reason.
RedirectMatch ^/(?!test\.html) http://www.example.com
Which means a slash, which is not followed directly by test.html. By leaving off the end anchor($), it will match anything besides /test.html. Hopefully ;)
There are complex solutions based on forwarding all server requests to a script that will handle the serving and redirection of requests, if you really want to get into that instead of looking for a host that will support your needs...
Jim