Forum Moderators: phranque

Message Too Old, No Replies

redirect index.php?var=val

         

mhamdi

2:19 pm on Apr 20, 2007 (gmt 0)

10+ Year Member



Hi I would like to redirect index.php?anyvar=anyval to /

I am using the code below but it only redirects index.php to /
any suggestions?

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php多tml?)\ HTTP/
RewriteRule ^index\.(php多tml?)$ http://www.example.com/ [R=301,L]

[edited by: jdMorgan at 3:02 pm (utc) on April 20, 2007]
[edit reason] example.com [/edit]

jdMorgan

2:42 pm on Apr 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This will redirect index.php?anyvar=anyval to /?anyvar=anyval:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php多tml?)[b][^\ ]*[/b]\ HTTP/
RewriteRule ^index\.(php多tml?)$ http://www.example.com/ [R=301,L]

To remove the query string, use:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php多tml?)[^\ ]*\ HTTP/
RewriteRule ^index\.(php多tml?)$ http://www.example.com/[b]?[/b] [R=301,L]

If you don't want or need this to apply to ".htm" and ".html" files as well, then replace the "(php多tml?)" with just "php".

Jim

mhamdi

2:57 pm on Apr 20, 2007 (gmt 0)

10+ Year Member



Thanks Jim,
I did exactly that but I get a 500 error.

mhamdi

3:00 pm on Apr 20, 2007 (gmt 0)

10+ Year Member



My bad, it works great!
I missed a space...