Welcome to WebmasterWorld Guest from 50.17.5.36

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

need to redirect /?SelectTopic=* to /

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

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 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!
12:33 am on July 25, 2011 (gmt 0)

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 0


Can anyone help me with this please?
12:53 am on July 25, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 11, 2001
posts:5408
votes: 2


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.
1:03 am on July 25, 2011 (gmt 0)

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 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....
1:14 am on July 25, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12708
votes: 244


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?
1:34 am on July 25, 2011 (gmt 0)

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 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.
2:53 am on July 25, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12708
votes: 244


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?
3:09 am on July 25, 2011 (gmt 0)

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 0


I want to redirect everything with ?Select to the home page.
3:28 am on July 25, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
posts:12708
votes: 244


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.