Forum Moderators: phranque
My home page URL has been indexed by Google in the form http://www.example.co.uk/?adCode=melon. I want to get rid of the /?adCode=melon bit and send a 301 redirect to Google so that my listing becomes http://www.example.co.uk.
I tried doing this with Redirect but it doesn't seem to work for form parameters. Some initial investigation leads me to believe that I need to use mod_rewrite with a RewriteCond of 'QUERY_STRING'. I've had a few goes at this but haven't managed to fix the problem.
Does anyone know how to write a RewriteRule to do this?
Thanks,
Frisky Bits
[edited by: jdMorgan at 6:03 pm (utc) on July 6, 2005]
[edit reason] Removed specifics per TOS. [/edit]
Jim
this is what I have come up with. It seems to work but I'm not totally sure why.
RewriteEngine On
RewriteLog logs/rewrite.log
RewriteLogLevel 9
RewriteCond %{QUERY_STRING} ^(.*)adCode(.*)$
RewriteRule ^(.*)$ http://www.example.co.uk? [R=301,L]
Does it look OK to you?
Regards,
Martin
[edited by: jdMorgan at 6:13 pm (utc) on July 7, 2005]
[edit reason] Obscured URL per Terms of Service. [/edit]
RewriteEngine On
RewriteLog logs/rewrite.log
# RewriteLogLevel 9
RewriteCond %{QUERY_STRING} adCode
RewriteRule .* http://www.example.co.uk/? [R=301,L]
If you want to retain some of the query parameters or retain the requested page name, then the code will require modification.
Jim