homepage Welcome to WebmasterWorld Guest from 54.196.201.253
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
need to redirect /?SelectTopic=* to /
starchild




msg:4342570
 4:45 am on Jul 22, 2011 (gmt 0)

Hi,

I'm sure this is a really simple thing, but i need to redirect all pages that begin with:

?Select

to /.

A range of the urls in question include:

?SelectTopic=%2523
/?SelectURL2=%2523
/?SelectURL=%2523
/?Selectb=%252523
/?Selectc=../category/test.html
/?gclid=CM6Rjuerp5YCFQVxFQodmX7Pzg
/?selectFees2=%2523
/?selectFees=%2523

What's the best way to do this please in apache htaccess?

Thanks!

 

starchild




msg:4343373
 12:33 am on Jul 25, 2011 (gmt 0)

Can anyone help me with this please?

wilderness




msg:4343376
 12:53 am on Jul 25, 2011 (gmt 0)

There's a recent thread on this:

gclid

Query strings are the most common questions in this forum, multiple times each week.

There are thousands of examples in the archives.

starchild




msg:4343378
 1:03 am on Jul 25, 2011 (gmt 0)

Hi wilderness, yes I appreciate that.

I;ve tried so many things, but these just do my head head, I can;t wrap my head round it at all I'm afraid....

lucy24




msg:4343382
 1:14 am on Jul 25, 2011 (gmt 0)

I think we're still trying to figure out what you mean. Are you trying to change certain query strings, or redirect them to a fixed url, or, or, or...?

And what's that Google Analytics string (gclid) doing in the middle of the examples?

starchild




msg:4343388
 1:34 am on Jul 25, 2011 (gmt 0)

ok, my apologies Lucy. I need all of those to redirect to /

Essentially, these have all been indexed by google and I need to get rid of the duplicate content.

The GA string was just in the list of urls indexed.

lucy24




msg:4343405
 2:53 am on Jul 25, 2011 (gmt 0)

Are you redirecting to your main page or to the index page of a directory called something like /select/ ?

RewriteCond %{QUERY_STRING} ^Select [NC]

will get you everything that has ?Select or ?select at the beginning of the query. Where (in English) do you want to send them? Does the ?Select query currently come attached to many different urls (looking only at the non-query part) or is the "real" url always the same?

starchild




msg:4343407
 3:09 am on Jul 25, 2011 (gmt 0)

I want to redirect everything with ?Select to the home page.

lucy24




msg:4343413
 3:28 am on Jul 25, 2011 (gmt 0)

To get rid of the query string:

RewriteCond %{QUERY_STRING} ^Select [NC]
RewriteRule .+ http://www.example.com/? [R=301,L]

Question mark followed by nothing means get rid of the query.

To keep the query string:

RewriteCond %{QUERY_STRING} ^Select [NC]
RewriteCond {something here} !^/(index.[a-z]+)?$
RewriteRule .+ http://www.example.com/ [R=301,L]

No question mark means keep the query unchanged.

{something here} means I don't remember exactly what it's called so you can jolly well look it up yourself [httpd.apache.org]-- and fix the wording while you're at it. The point here is that if you're redirecting to the front page and keeping the query string, you have to exclude the ones that are already asking for the front page or it will keep redirecting forever.

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