Forum Moderators: phranque

Message Too Old, No Replies

Ridding the Tracking Codes in a 301 Redirect

         

bears5122

7:35 am on Jun 11, 2006 (gmt 0)

10+ Year Member


I'm at my wits end here with a redirect. I purchased a domain that had some old tracking/affiliate codes out there and indexed. A lot of the links coming in are to these:

Example: http://www.olddomain.com/?click=45345

Now I want to 301 this domain and any possible page to my new domain. I'm using the following code:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule ^(.*)$ http://www.newdomain.com [R=301,L]

Works just fine with the exception of one small glitch. The affiliate/tracking codes are passing through.

Example: http://www.olddomain.com/?click=4443 is redirecting to http://www.newdomain.com/?click=4443

I just can't figure out how to stop that. I want everything to go clean to http://www.newdomain.com.

I know it's probably something simple I'm missing, but any help would be greatly appreciated.

jdMorgan

3:36 pm on Jun 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As discussed in the RewriteRule documentation, you can clear the query string by appending a "?" to the substitution URL. Along with several other functional and speed tweaks, it looks like this:

RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]
RewriteRule (.*) http://www.newdomain.c[b]om?[/b] [R=301,L]

See also this thread [webmasterworld.com] for side-effects.

Jim