ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Google Adwords adds in ?gclid= which kills EE

July 22, 2008 8:07pm

Subscribe [17]
  • #31 / Aug 14, 2008 12:15pm

    nyeoman

    94 posts

    Sure here it is:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        
        RewriteRule ^\?(gclid=.*)$ /index.php/$1 [R,L]
        
        #This piece I stole from one of my code igniter sites
        #Removes access to the system folder by users.
        #Additionally this will allow you to create a System.php controller,
        #previously this would not have been possible.
        #'system' can be replaced if you have renamed your system folder.
        RewriteCond %{REQUEST_URI} ^system.*
        RewriteRule ^(.*)$ /index.php/$1 [L]
    
        #Checks to see if the user is attempting to access a valid file,
        #such as an image or css document, if this isn't true it sends the
        #request to index.php
        RewriteCond %{REQUEST_METHOD} !^POST$ [NC] 
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L]
        
        
    
    </IfModule>
    
    AddType application/x-httpd-php .xml
    #Disable directory browsing
    Options -Indexes
  • #32 / Aug 19, 2008 9:10pm

    eyevariety

    158 posts

    Adhesion, did you get it figured out? Wondering what you solution was. Thanks

  • #33 / Aug 19, 2008 9:25pm

    adhesion

    15 posts

    Adhesion, did you get it figured out? Wondering what you solution was. Thanks

    No luck here, I’m still working through it. I will definitely post the resolve here in it’s entirety to help others through it.

    In saying that some have already solved the issue by using an .htaccess rewrite, there’s a few threads similar to this one.

    For now, we aren’t running what we call “brand ads” that send users to the homepage, as other pages within the websites work just fine.

    If you come to a solution first, I’d be interested in your fix also !

  • #34 / Feb 05, 2009 1:03pm

    Corey Snipes

    34 posts

    The code below is working for us.  There may be more elegant approaches or more concise ways to write the rules, but here ‘tis.  Our campaigns come in with “_kk=” instead of “gclid=”, so adjust to your personal situation.

    RewriteEngine on
    
    # Catch any Google campaigns directed to the home page
    RewriteCond %{REQUEST_URI} ^/$
    RewriteCond %{QUERY_STRING} ^(_kk=.*)
    RewriteRule ^(.*)$ /index.php/ [L,PT]
    
    # Everything else to the EE controller
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
  • #35 / Apr 14, 2009 12:39am

    adhesion

    15 posts

    Many thanks Corey! I’ve taken the code you’d posted and re-worked it for our situation and it works perfectly.

    It’s great to have such a clean fix to this issue.

    This thread can now be closed off.

  • #36 / Apr 14, 2009 9:01pm

    Corey Snipes

    34 posts

    Good deal; I’m glad it was helpful.

  • #37 / May 21, 2009 6:51am

    Andrew Armitage

    86 posts

    Thanks Corey - this worked for me to.

  • #38 / Oct 31, 2009 5:21pm

    Davor

    114 posts

    Thanx Corey, that fixed my problems with google url too in this topic http://ellislab.com/forums/viewthread/133791/

  • #39 / Mar 18, 2010 4:36am

    narendra

    44 posts

    Corey,

    I am still facing issue.

    http://www.deltacharterbus.com/?gclid=CMmk9PWimKACFRknawodqz3gnA

    This my site and I have used your code in my .htacess file but it’s not working.

    404 is enabled in my site, does that create any problem?

    Any help much appreciated.

  • #40 / Apr 12, 2010 10:18am

    Matthieu Fauveau

    106 posts

    Thanks Corey, it’s working for me now too.

    Just a slight change if you use a server with Fastcgi/Fcgid (the important thing is the question mark after index.php) :

    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 except files and directories to the EE controller
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteRule ^(.*)$ /index.php?$1 [L]
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases