Forum Moderators: phranque

Message Too Old, No Replies

yet another rewrite question

mod rewrite

         

belfasttim

5:38 am on Jun 17, 2009 (gmt 0)

10+ Year Member



Hi mod_rewrite/mod_alias gurus--

I am seeing a lot of my pages in google looking like this:
mydomain.com/?limitstart=456
mydomain.com/?limitstart=345
etc.

I'd like to redirect these back to the index page-- but I'm not sure how to go about that, since it appears the ? is messing things up. Shouldn't a simple:

Redirect permanent /?limitstart http://example.com/

work? It doesn't. . .

Thanks for any tips.

[edited by: jdMorgan at 1:30 pm (utc) on June 17, 2009]
[edit reason] example.com [/edit]

jdMorgan

1:30 pm on Jun 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No that won't work, because a query string is not part of a URL, but only data attached to a URL, and intended to be passed to the resource at that URL. Therefore, Apache directives which examine URLs cannot 'see' query strings.

You will need to use mod_rewrite to examine the query strings.

Assuming that you already have other working mod_rewrite rules, you could use:


RewriteCond %{QUERY_STRING} ^limitstart=
RewriteRule ^$ http://example.com/? [R=301,L]

to implement the function you were trying to achieve with the Redirect directive.

However, you need to ask yourself, "How did these querystring URLs get into the search index in the first place?" Before implementing this redirect, be sure that there are no links on your site to those "bad" URLs. If there are, then you must correct them before implementing this redirect. Otherwise, you will see many errors in your Google Webmaster Tools report, and your 'quality score' may be negatively affected.

Jim

belfasttim

4:52 pm on Jun 17, 2009 (gmt 0)

10+ Year Member



thanks for the thorough reply Jim!