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.

404 when using querystring

October 18, 2011 7:08am

Subscribe [5]
  • #1 / Oct 18, 2011 7:08am

    Russ Back

    142 posts

    Not sure where to start on this one…

    We’re finding that any links that feature a querystring redirect to a 404. So for example a Google Adwords link that might look lik http://www.domainname.com/?gclid=CIaz2IWC8qsCFUNO4QodNBHSwg goes to a 404 instead of the home page.

    Is there a way to tell EE to ignore anything from ? and beyond?

    [color=purple]Moved to Community Help forum by Moderator[/url]

  • #2 / Oct 18, 2011 9:19am

    jonathanmelville

    132 posts

    This is happening because you are using mod_rewrite to hide index.php from your URLs with an .htaccess file.

    You can tack this on to the bottom of your .htaccess file and it will catch incoming Google campaigns and redirect them properly to your front page.

    # Catch incoming Google campagins
    
    RewriteCond %{REQUEST_URI} ^/$
    RewriteCond %{QUERY_STRING} ^(gclid=*)
    RewriteRule ^(.*)$ /index.php?/$1 [L]
  • #3 / Oct 18, 2011 9:25am

    Russ Back

    142 posts

    I suspected it might be something like this, but I was barking up the wrong tree looking at the Structure module and it’s URLs.

    Thanks Jonathan, I’ll give this a try.

  • #4 / Oct 18, 2011 9:28am

    Sue Crocker

    26054 posts

    Thanks for the assist, Jonathan.

    Russ, this is just a bit beyond the scope of official support, so moving this thread to the Community Help forum.

  • #5 / Oct 19, 2011 11:18am

    Russ Back

    142 posts

    The above rewrite works for the home page, but on any other URL I still get a 404. Any ideas?

    This is fine:
    http://domain.com/?gclid=adsadadasdasasd

    As is this:
    http://local.myredlandroof.com/some/url/

    This 404s:
    http://local.myredlandroof.com/some/url/?gclid=adsadadasdasasd

    As does this:
    http://local.myredlandroof.com/some/url?gclid=adsadadasdasasd

  • #6 / Oct 20, 2011 9:17pm

    the3mus1can

    426 posts

    This is because the default $config[‘uri_protocol’] is set to AUTO.  This looks first for the uri path as a query string and if you use the above rewrite it will find more than it needs there if you are using other query string variables.

    I suggest you use this rewrite:

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

    And change the uri_protocol to either PATH_INFO or REQUEST_URI.  This setting will largely depend on the configuration of the server that you are on.

  • #7 / Oct 25, 2011 4:28pm

    Russ Back

    142 posts

    Thanks the3mus1can.

    I already have that rewrite in place courtesy of the NSM .htaccess Generator add-on. However switching to uri_protocol to PATH_INFO nailed it.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases