1

我在同一个虚拟主机上运行 2 个域

<VirtualHost *:80> 
    ServerName www.example.de
    ServerAlias www.example.de example.de example.co.uk www.example.co.uk
    DocumentRoot C:/inetpub/wwwroot/example_ml
    DirectoryIndex index.php
</VirtualHost>

并尝试在我的 htaccess 中为两个域应用相同的重定向规则

RewriteRule ^tag/(.*)$ http://www.example.de/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/\d{2}/(.*)$ http://www.example.de/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/(.*)$ http://www.example.de/$1 [L,R=301]

RewriteRule ^tag/(.*)$ http://www.example.co.uk/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/\d{2}/(.*)$ http://www.example.co.uk/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/(.*)$ http://www.example.co.uk/$1 [L,R=301]

但似乎不适用于example.co.uk/tag_name我被重定向到的每一个example.de/tag_name

4

1 回答 1

0

你不需要定义规则两次,试试这个:

RewriteRule ^tag/(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/\d{2}/(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
RewriteRule ^\d{4}/\d{2}/(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
于 2012-09-13T09:37:38.083 回答