Reputation: 156
I discovered the UTM variables for Google Analytics bust our page caching. Google Analytics allows using hash instead of question mark, so
http://www.example.com/?utm_source=source&utm_medium=medium
and
http://www.example.com/#utm_source=source&utm_medium=medium
Are actually the same. But, as I said, the first option busts our caching while the second does not.
When we generate our own links, then I use #
. However, services like Feedburner or dlvr.it
append the UTM campaign variables with a ?
-- so I want in .htaccess
to redirect all /?utm...
to /#utm...
I know that NE
(No Escape) should be used for the hash, but I honestly can't figure out how the rewrite condition and rule should be like.
The rule logic should be -
RewriteCond: if {path}?{query_string} AND {query_string} has 'utm_source' as a variable,
RewriteRule: redirect to {path}#{query_string} [R,NE,L]
Can anyone help me with this place?
Upvotes: 2
Views: 68
Reputation: 156
OK, I got a eureka shortly after asking the question...
The solution is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} utm_source
RewriteRule ^ %{REQUEST_URI}#%{QUERY_STRING}? [R,NE,L]
</IfModule>
Tested and works...
Upvotes: 1