阿帕奇重写preserve查询字符串 [英] Apache rewrite to preserve query string

查看:192
本文介绍了阿帕奇重写preserve查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组根据下属公司,重写URL规则。一切工作正常 不过,我有一个问题,preserving在URL中的完整的查询字符串。 这是我重写规则

 重写规则^ /(。* \。HTML)/adb.pl?$c$c=${aff$c$c:$1}&extra=%{QUERY_STRING} [PT,L]
 

在URL查询后AFF code被剥离。

URL应该是这样的:

<$p$p><$c$c>http://mydomain.com?utm_campaign=TEST-AFF&utm_source=TEST-AFF&utm_medium=TEST-AFF&utm_term=TEST-AFF&utm_content=TEST-AFF-JON

相反,我得到这个在我的浏览器:

  http://mydomain.com?utm_campaign=TEST-AFF
 

我已经尝试使用QSA和NE标志。但只要[PT]是有它拒绝工作。任何帮助将是AP preciated。

谢谢!

解决方案

问题你面对无关与的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.

这篇关于阿帕奇重写preserve查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆