Forum Moderators: phranque
My website has recently been changed to be virtually hosted (with a domain name all of it's own) but on the same server as before. So all the old URLs still automatically serve the correct pages, because they point to the "real" resource locations.
I.e. [medphysics.leeds.ac.uk...]
becomes [revisemri.com...]
I am simply trying to redirect all old-URL requests to the new URL form. I have accomplished this with RedirectMatch:
RedirectMatch ^/~dmh/mri/(.*) [revisemri.com...] [R=301,L]
This would be fine except some one of my cgi-bin programs doesn't work. I would therefore like to exclude the cgi-bin directory from the URL redirect instruction. Could anyone tell me why the following doesn't accomplish this? (I get an 500 internal server error on all pages for either domain)
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*)/~dmh/mri/cgi\-bin/(.*) [S=1]
RewriteRule ^(.*)/~dmh/mri/(.*)$ [revisemri.com...] [R=301,L]
The server is Apache/1.3.22 (Unix).
Thanks alot
Dave Higgins
*******************************ADDED:
Got it!
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI}!^(.*)/~dmh/mri/cgi\-bin/(.*)
RewriteRule ^(.*)/~dmh/mri(.*)$ [revisemri.com$2...] [R=301,L]
Note the exclamation mark, essentially meaning NOT.
HOWEVER, even though the redirect rule is specified in the text R=301, the address
is not rewritten in the client browser, which kind of defeats the point, really. Or is it actually not working?
Any ideas?
Thanks
Dave
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{REQUEST_URI} !^/~dmh/mri/cgi-bin/
RewriteRule ^~dmh/mri(.*)$ http://www.example.com$1 [R=301,L]