Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite directory

mod rewrite a directory

         

mhamdi

6:31 am on Dec 29, 2006 (gmt 0)

10+ Year Member



I want to redirect
www.example.com/forums/* to www.example.com/
for example www.example.com/forums/forumdisplay.php?f=30 to www.example.com/

I did this:
RewriteRule ^forums/(.*)$ http://%{HTTP_HOST}/ [R=301,L]

It works "fine" but instead of being redirected to www.example.com/ It is redirecting to www.example.com/?f=30 for the example above.

any suggestions?

[edited by: jdMorgan at 6:55 am (utc) on Dec. 29, 2006]
[edit reason] example.com. [/edit]

jdMorgan

6:52 am on Dec 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add a question mark to the substitution URL to clear the query string:

RewriteRule ^forums/(.*)$ http://%{HTTP_HOST[b]}/?[/b] [R=301,L]

This is documented in the notes in the RewriteRule documentation [httpd.apache.org].

Jim

mhamdi

6:56 am on Dec 29, 2006 (gmt 0)

10+ Year Member



It works, Thank you much!