homepage Welcome to WebmasterWorld Guest from 54.166.108.167
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

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




msg:1497091
 4:31 am on Jun 10, 2005 (gmt 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?

Thanks!

 

Billy Batson




msg:1497092
 5:05 am on Jun 10, 2005 (gmt 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]

jdMorgan




msg:1497093
 3:50 pm on Jun 10, 2005 (gmt 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/

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved