Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Htaccess: problems with rewriting for the gclid querystring

    I have problems with rewriting for the gclid querystring (Google Adwords).
    This is what I want:

    http://www.domain.com/?gclid=abcdetc
    should be:
    http://www.domain.com/redirect,?gclid=abcdetc

    http://www.domain.com/page/?gclid=abcdetc
    should be:
    http://www.domain.com/page/redirect,?gclid=abcdetc

    http://www.domain.com/page/subpage/?gclid=abcdetc
    should be:
    http://www.domain.com/page/subpage/redirect,?gclid=abcdetc

    This is a part of my htaccess:

    ## search for query string "gclid"
    RewriteCond %{QUERY_STRING} ^(gclid=.*)$
    ## ignore url's with "redirect,"
    RewriteCond %{REQUEST_URI} !(.*?)redirect,(.*?)$

    ... a redirect rule over here ? ...

    ## get mvc index to build site
    RewriteRule (.*) /html/$1 [L]

    Please tell me how to solve this.

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    363
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Try
    Code:
    Options +FollowSymLinks
    
    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^(.*&)?gclid= [NC]
    RewriteCond %{REQUEST_URI} ^/$ [OR]
    RewriteCond %{REQUEST_URI} ^(/.*[^/])/?$
    RewriteRule !^(.+/)?redirect,$ %1/redirect, [R=301,L]

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your reply!

    This is the result right now:
    http://www.domain.com/index.php/redirect,?gclid=abcdetc

    It rewrites "/page/subpage/" also to "index.php/"

    I would like to rewrite the current path in it.
    Do you have a solution for it?

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Posts
    363
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Do you have any more RewriteRules? Could you post them all.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •