Bob Smith wrote:
> I'm trying to remove two directories from the path of a website, but I just
> can't seem to get the mod_rewrite syntax right.
>
> I have a url coming in with a url like
> http://www.mysite.com/directoryone/directorytwo/mypage.php?key=value
>
> And I'm trying to redirect it to http://www.mysite.com/mypage.php?key=value
Are your directories constants? Or are they some kind variable?
To force such an external redirect, you could use in your httpd.conf
RewriteRule ^/directoryone/directorytwo/(mypage\.php)$ /$1 [R=301,L]
Yeah, the directories I want to remove will be the same. but the pages will be different (I'm hoping I don't have to do one for each individual page)
I tried:
RewriteEngine On
RewriteRule ^/directoryone/directory/two/(.*)$ /$1 [QSA,R=301]
But that's throwing a 500 error