htaccess的重写URL附加谷歌广告活动追踪导致重定向循环

问题描述:

我们正试图跟踪离线广告使用指向我们的主网站的网址别名。我们需要追加谷歌分析系列跟踪code到URL的末尾时所访问的别名域之一。

We are attempting to track offline campaigns to using aliased URLs that point to our main site. We need to append Google analytics campaign tracking code to the end of the URL when the domain is one of the aliased domains.

下面重定向追加正确的信息,但会导致重定向循环,我将承担因的RewriteCond仍然匹配的规则被应用后为真。

The following redirect appends the correct information but causes a redirect loop, which I would assume because the RewriteCond still matches as true after the RewriteRule is applied.

RewriteCond %{HTTP_HOST} ^bikerhelp911\.com$
RewriteRule (.*) http://bikerhelp911.com/?utm_source=bikerhelp911.com&utm_medium=radio&utm_campaign=Radio%2BCampaign$1 [R=302,L]

我觉得我可能这样做了错误的方式,或使其更复杂得多它需要。

I feel like I'm probably doing this the wrong way or making it more complicated than it needs to be.

更​​改code到这一点:

Change your code to this:

RewriteCond %{QUERY_STRING} !utm_campaign= [NC]
RewriteCond %{HTTP_HOST} ^bikerhelp911\.com$
RewriteRule ^(.*)$ /?utm_source=bikerhelp911.com&utm_medium=radio&utm_campaign=Radio%2BCampaign$1 [R=302,L,QSA]