Created
June 27, 2014 00:18
-
-
Save insparrow/74ca7a828fbce00b79d1 to your computer and use it in GitHub Desktop.
Using mod_rewrite to preserve url args (such as gclid) throughout your site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine on | |
# If 'gclid' argument exists in referring URL and this is an article, | |
# append argument to requested URL. | |
RewriteCond %{QUERY_STRING} !^gclid= | |
RewriteCond %{REQUEST_URI} ^/articles\/(.*)$ [NC] | |
RewriteCond %{HTTP_REFERER} ^(.*)?gclid=([^&]+) | |
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1?gclid=%2 [QSA,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment