Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite in query string

Mod Rewrite in query string

         

kirang

2:15 pm on May 10, 2007 (gmt 0)

10+ Year Member



Hello,
I want to redriect my url as

[sitename.com...]
to
[sitename.com...]

what should i do?
And also i only need to redirect "?keyword=&currentpage=1" not for "?keyword=&currentpage=2" or any other query string.

I tried this -
RewriteRule ^writingtips(.*)keyword(.*)currentpage=1$ [sitename.com...] [R=301,L] but now working.

Thanks,

jdMorgan

4:30 pm on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> what should i do?

You must use RewriteCond to test the query string, and you must append a "?" to the new URL to clear the current query string:


RewriteCond %{QUERY_STRING} ^keyword=&currentpage=1$
RewriteRule ^writingtips\.php$ http://www.example.com/writingtips.ph[b]p?[/b] [R=301,L]

The "?" on the new URL will not appear in the redirected URL -- It just tells mod_rewrite to erase the "keyword=&currentpage=1" query string, which would otherwise be 'passed through' the rule unchanged.

Jim