我有多个辅助域重定向到我的主域。
实施例。这将被写入www.secondarydomain1.com的htaccess:
RewriteEngine On
RewriteRule ^(.*)$ http://primarydomain.com/?utm_source=redirect&utm_medium=secondarydomain1.com&utm_campaign=301redirect$1 [R=301,L]
我如何编写www.primarydomain.com的htaccess,以便符合以下条件:
如果网址为http://primarydomain.com/?utm_source=redirect&utm_medium=secondarydomain1.com&utm_campaign=301redirect或http://primarydomain.com/?utm_source=redirect&utm_medium=secondarydomain2.com&utm_campaign=301redirect等, 重定向回到primarydomain.com?
答案 0 :(得分:1)
将此代码放入DOCUMENT_ROOT/.htaccess
文件中:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?primarydomain\.com$ [NC]
RewriteCond %{QUERY_STRING} ^utm_source=redirect&utm_medium=((secondarydomain1|secondarydomain2)\.com|secondarydomain3\.me)&utm_campaign=301redirect$ [NC]
RewriteRule ^ /? [L,R=302]