Forum Moderators: phranque

Message Too Old, No Replies

Redirect question about parameters

         

fatabbot

3:01 pm on Jul 12, 2009 (gmt 0)

10+ Year Member



Hi,
I noticed google indexed several versions of my index page, for example:

[mydomain.com...]
[mydomain.com...]
[mydomain.com...]
[mydomain.com...]

etc...
This is due a 301 redirect i did from an old domain to the this domain, which didnt strip any of the parameters...

I'd like to permanently redirect all versions of [domain.com...] to [domain.com...]

How can this be done via a mod rewrite rule in htaccess?

Best regards

jdMorgan

6:39 pm on Jul 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By adding a "?" to the substitution URL in your RewriteRule to clear the existing query string, as documented.

Jim

fatabbot

6:56 pm on Jul 12, 2009 (gmt 0)

10+ Year Member



This is my existing rule:
RewriteRule \^(.*)$\ www.mydomain.com/ [R=301,L]

It doesn't work for some reason...

I tried with the ? too, but no result

RewriteRule \^(.*)$\ www.mydomain.com/? [R=301,L]

When I go to [mydomain.com...] it just stays on that url instead of going to [mydomain.com...]

Any ideas?

jdMorgan

7:10 pm on Jul 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assuming that you already have other working RewriteRules in this file:

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

Be sure to completely flush (delete) your browser cache before testing any new server-side code.

Jim

fatabbot

7:52 pm on Jul 12, 2009 (gmt 0)

10+ Year Member



That seems to work.
Thanks a lot for your quick response jdMorgan, much appreciated!