2

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.

2
  • 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, 2011 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, 2011 at 2:50

3 Answers 3

1

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

1
  • thanks, but i need to see it with my conditions
    – Jeffrey
    May 1, 2011 at 2:48
0

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.

0

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 

</IfModule>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.