Welcome to WebmasterWorld Guest from 54.211.101.8

Forum Moderators: Ocean10000 & incrediBILL & phranque

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

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

5+ Year Member



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?

Thanks!

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

5+ Year Member



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 Jun 10, 2005 (gmt 0)

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



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/

Jim

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month