我正在使用 Apache 2.4 来托管这些域:
domena.pl/
domena.pl/ru
domena.pl/en
我需要将 domena.com 重定向到 domena.pl/en。这是我的 htacces 文件:
RewriteCond %{HTTP_HOST} ^(www\.)?domena\.ru
RewriteCond %{REQUEST_URI} "^/pl$"
RewriteRule ^(.*)$ http://www.domena.pl/pl [R=303,NC,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domena\.ru
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule ^(.*)$ http://www.domena.ru/ru [R=303,NC,L]
RewriteCond %{HTTP_HOST} !^(www.domena.pl|www.domena.ru)$
RewriteRule ^(.*)$ http://www.domena.pl/$1 [R=301,L]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
RewriteRule ^/*$ cached/index.html [L]
答案1
您只需要添加另一条规则,其他规则如下:
RewriteCond %{HTTP_HOST} ^(www\.)?domena\.com
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule ^(.*)$ http://domena.pl/en [R=303,NC,L]
您需要先添加此规则RewriteCond %{HTTP_HOST} !^(www.domena.pl|www.domena.ru)$
才能触发