I've got an url coming in as:

/index.php?/location/&gclid=287ejek22kj


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

I need it to go to:

/index.php?/location


I've tried this, with no success:

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


All help is appreciated. Thanks.

-

## migrated from serverfault.comMay 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

This is pretty much answered in concept at least here: http://stackoverflow.com/questions/2111182/rewriting-url-with-selected-query-string-parameters-in-htaccess

-
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.

-

Try this (you :

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/$RewriteCond %{QUERY_STRING} ^(gclid=.*) RewriteRule ^(.*)$ /index.php/ [L,PT]