
[英]rewrite rule, two domains pointing to same directory, redirect one file at one domain
[英]same redirect rule on 2 domains
我在同一虛擬主機上運行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
您無需兩次定義規則,請嘗試以下操作:
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]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.