更新时间:2023-02-24 10:41:11
问题你面对无关与的mod_rewrite
。你必须在谷歌的运动,对不对?所有这些 utm_something
只是为。您可以从谷歌一个JS为这项运动,对不对?
因此,它的工作原理是这样的:
- JS从查询字符串将这些额外的参数
- 然后将浏览器重定向到谷歌分析网址发送这些参数
- 谷歌Analytics(分析)抓住这一请求,并记录从活动降临到你的页面***问
- GA发送HTTP重定向响应浏览器,指向所有utm_something剥离原来的网址
为什么呢?因为如果他们没有被剥夺,JS会再次抓住他们,这将导致重定向的死循环。
I have a set of rules that rewrite URL depending on the affiliate. Everything works fine However, I'm having a problem preserving the complete query string in URL. Here's my rewrite rule
RewriteRule ^/(.*\.html) /adb.pl?code=${affcode:$1}&extra=%{QUERY_STRING} [PT,L]
The query in URL gets stripped after affcode.
URL should look like this:
http://mydomain.com?utm_campaign=TEST-AFF&utm_source=TEST-AFF&utm_medium=TEST-AFF&utm_term=TEST-AFF&utm_content=TEST-AFF-JON
Instead I'm getting this in my browser:
http://mydomain.com?utm_campaign=TEST-AFF
I have already tried using QSA and NE flags. But as long as [PT] is there it refuses to work. Any help would be appreciated.
Thanks!
The "problem" you are facing has nothing to do with mod_rewrite
. You have a campaign in Google, right? All these utm_something
are just for that. You have a JS from Google for this campaign, right?
So it works this way:
- JS takes these extra parameters from the query string
- then it redirects the browser to Google Analytics URL sending these parameters
- Google Analytics grabs this request and records the visit on your page coming from campaign
- GA sends HTTP redirect response to browser pointing to original URL stripped from all utm_something
Why? Because if they were not stripped, JS would grab them again and this will lead to endless loop of redirects.