【发布时间】:2019-07-13 08:10:38
【问题描述】:
我们有一个非常大的 .htaccess 文件,我们在其中创建基于不同域 RewriteCond 的 RewriteRules。我们使用 [OR] 标志来确保同时满足“www”和域条件,然后重定向到特定页面。
示例:
# DOMAIN 1
RewriteCond %{HTTP_HOST} ^domain1\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain1\.com$
RewriteRule ^en/contact$ https://domain1.com/en/contact.html [L,R=301]
RewriteRule ^fr/nouvelles$ https://domain1.com/fr/articles.html [L,R=301]
RewriteRule ^en/career$ https://domain1.com/en/career.html [L,R=301]
RewriteRule ^fr/contact$ https://domain1.com/fr/contact.html [L,R=301]
# DOMAIN 2
RewriteCond %{HTTP_HOST} ^domain2\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain2\.com$
RewriteRule ^fr/maison-payante$ https://domain2.com/fr/articles.html [L,R=301]
RewriteRule ^en/cash-damming$ https://domain2.com/en/articles.html [L,R=301]
RewriteRule ^fr/nos-proprietes$ https://domain2.com/fr/nos-proprietes.html [L,R=301]
RewriteRule ^en/40km-program$ https://domain2.com/en/articles.html [L,R=301]
RewriteRule ^fr/mes-proprietes$ https://domain2.com/fr/nos-proprietes.html [L,R=301]
RewriteRule ^en/our-properties$ https://domain2.com/en/our-properties.html [L,R=301]
问题
访问http://domain1.com/en/40km-program 将重定向到https://domain2.com/en/articles.html。
即使不满足 RewriteCond,也会应用以下规则:
RewriteRule ^en/40km-program$ https://domain2.com/en/articles.html [L,R=301]
.htaccess 文件语法看起来不错(在两个不同的语法检查工具中检查)。
怎么会这样?
感谢您的帮助。
【问题讨论】:
标签: apache .htaccess redirect mod-rewrite apache2