longtone Posted January 17, 2010 Share Posted January 17, 2010 I want to redirect all pages a directory to one page outside that directory eg: /folder/somepage.php to /anotherpage.php and ideally add a query string: /folder/somepage.php to /anotherpage.php?sv=somepage I thought this would do it: Redirect /folder/([a-zA-Z0-9]+)$ http://www.example.com/anotherpage.php?sv=$1 but it doesn't... Can anyone see what I'm doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/188735-how-to-redirect-entire-directory-to-one-page/ Share on other sites More sharing options...
trq Posted January 17, 2010 Share Posted January 17, 2010 You won't to use mod_rewrite, not a redirect. RewriteRule /folder/([a-zA-Z0-9]+)$ /anotherpage.php?sv=$1 Quote Link to comment https://forums.phpfreaks.com/topic/188735-how-to-redirect-entire-directory-to-one-page/#findComment-996340 Share on other sites More sharing options...
longtone Posted January 17, 2010 Author Share Posted January 17, 2010 You're right, I was confusing the two Actually what I ended up doing was both: Redirect /folder/ http://www.example/anotherpage/ RewriteRule ^anotherpage/([a-zA-Z0-9]+)?$ anotherpage.php?sv=$1 which gives the new url in the address bar but without the query string Thanks Quote Link to comment https://forums.phpfreaks.com/topic/188735-how-to-redirect-entire-directory-to-one-page/#findComment-996672 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.