Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Query String Redirect... How Do I Do It?

4:31 am on Jun 10, 2005 (gmt 0)

New User

10+ Year Member

joined:May 30, 2005
votes: 0

Over on the Bourbon Update thread Justin was telling me how to 301 a link to the index of mydomain with a long obsolete parameter call on it:

RewriteCond %{HTTP_HOST} ^mydomain\.com\?[parameter] [NC]

You will need to use %{QUERY_STRING}. I would elaborate, but this is an update thread. =)

If you are stuck, please post in the Apache forum.

I'm stuck... how do I do this redirect, please?


5:05 am on June 10, 2005 (gmt 0)

New User

10+ Year Member

joined:May 30, 2005
votes: 0

Actually, I think I have solved the issue:

Options +FollowSymLinks 
RewriteCond %{query_string} ^aaaa=bbbb.htm
RewriteRule index\.htm$ http://www.example.com/? [R=301,L]

Or is this going to break and make Google angry somehow?

[edited by: jdMorgan at 3:50 pm (utc) on June 10, 2005]
[edit reason] Examplified. [/edit]

3:50 pm on June 10, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0

It's OK, as long as you're aware that it will redirect index.html in any (sub)directory to your home page.

Since you didn't state what you're trying to accomplish or give background information on your current site structure, I can't say if it will hurt your rankings in Google.

You can make it more specific by start-anchoring the URL pattern. Further, you should escape all literal characters, including those in the query string:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^aaaa=bbbb\.htm
RewriteRule ^index\.htm$ http://www.example.com/? [R=301,L]

That will redirect requests for www.example.com/index.html?aaaa=bbb\.htm to www.example.com/