简体   繁体   English

htaccess重写网址以追加导致重定向循环的Google广告系列跟踪

[英]htaccess rewrite URL to append Google campaign tracking causing redirect loop

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. 当域是别名域之一时,我们需要将Google分析广告系列跟踪代码附加到URL的末尾。

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在应用RewriteRule后仍然匹配为true。

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. 我觉得我可能是以错误的方式做这件事,或者让它变得比它需要的更复杂。

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM