Forum Moderators: phranque
RewriteRule (.*)]$ $1 [L,R]
But lo and behold, when I test it my browser redirects to:
http://mydomain.com/home/user/mydomain.com/subdir/page.html
What the heck? Okay, so I figure I'll just match only what comes after the "subdir":
RewriteRule subdir/(.*)]$ $1 [L,R]
But when I do that no match happens at all. I type <http://mydomain.com/subdir/page.html]> in my browser and just get a 404 error, no redirect.
What's going on here?
Try using
RewriteBase /home/user/mydomain.com/
to tell mod_rewrite how you got to the current location -- See RewriteBase directive in mod_rewrite docs for more info.
The RewriteBase path shown above may need some tweaking. It should include anything "extra or unexpected" that you find in the path reported to have caused an error. I'm not sure if I got it exactly right.
[added] I strongly suggest that you use [R=301,L] to generate a 301 redirect in this case, rather than the default 302. [/added]
Jim