Forum Moderators: phranque

Message Too Old, No Replies

Google Adwords adds in ?gclid= which kills my mod rewrite

         

artlab

8:22 pm on Jul 23, 2008 (gmt 0)

10+ Year Member



Google Adwords seems to create links of the form
[sitename.com?gclid=somecode...]

where somecode changes based on the ad

I am using a CMS and mod rewrite to to shorten URLs and remove the index.php file.

My current mod rewrite is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

But if I give the URL [sitename.com?gclid=somecode...]
I get an error page not found.

I am at a loss how to modify the mod rewrite so that
[sitename.com?gclid=somecode...]
still gets processed as [sitename.com...]

I tried changing to
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^/([^/]*)$ /?gclid=$1 [L]

but no luck.

Any mod rewrite experts know this one right off hand
(I am using ExpressionEngine CMS if that makes any difference)

Thanks

jdMorgan

12:14 am on Jul 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I am using a CMS and mod rewrite to to shorten URLs and remove the index.php file.

It may help you to understand that you are using mod_rewrite to tell the server to deliver content from the "longer" server filepath by adding "/index.php" when the "short" URL+query string is requested by a client (browser or robot), and that what you seem to want to do is to remove the query string "gclid=somecode".

Query strings can be cleared in mod_rewrite by appending a "?" to the substitution path:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/[b]$1?[/b] [L]

See the Apache mod_rewrite documentation for more information.

Jim