Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I've got an url coming in as:


This is going to a 404 page because of the gclid...

I need it to go to:


I've tried this, with no success:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)&gclid=(.*)$  $1 [L]

All help is appreciated. Thanks.

share|improve this question

migrated from May 1 '11 at 7:08

This question came from our site for system and network administrators.

is there a reason you're leaving in the /index.php? I assume that's your controller script, but using rewrites, you could easily make it simply make it /location. The main issue with what you're trying to do is that you're trying to capture the QUERY_STRING (everything after the ?). You need to treat this specially in RewriteRules –  djdrey May 1 '11 at 2:26
in the next set of rules i'm removing the index.php... but i'm having the issue with simply ignoring the gclid... on those adword pages only of course –  Jeffrey May 1 '11 at 2:50

3 Answers 3

This is pretty much answered in concept at least here:

share|improve this answer
thanks, but i need to see it with my conditions –  Jeffrey May 1 '11 at 2:48

I'm not sure how you're ending up with AdWords auto tagging appended to a URL without the proper structure but if you don't want the gclid parameter at all you could alway just switch off autotagging in AdWords. You shouldn't need to remove it using a rewrite rule as it's just an option that you can choose not to use.

share|improve this answer

Try this (you :

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /

  # Catch any Google campaigns directed to the home page
  RewriteCond %{REQUEST_URI} ^/$
  RewriteCond %{QUERY_STRING} ^(gclid=.*)
  RewriteRule ^(.*)$ /index.php/ [L,PT]

  # Everything else 

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.