Welcome to WebmasterWorld Guest from 54.226.67.166

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

need to redirect /?SelectTopic=* to /

     

starchild

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

10+ Year Member



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

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

10+ Year Member



Can anyone help me with this please?

wilderness

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

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



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

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

10+ Year Member



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

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

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



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

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

10+ Year Member



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

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

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



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

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

10+ Year Member



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

lucy24

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

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



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month