我试图重写域名,然后redirect到一个新的页面。
因此,project1.com,www.project1.com,project2.co.nz和www.project2.co.nz结束所有redirect到新域名http://newsite.com罚款。
但是我需要project1.com/2012去http://newsite.com/blog/archive ?
我已经从域重写规则删除L ,以允许它评估最后的重写规则…但没有喜悦?
<VirtualHost *:80> ServerName project1.com ServerAlias www.project1.com project2.co.nz www.project2.co.nz Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} !^newsite\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*) http://newsite.com/$1 [R=301] # project1.com/2012 needs to go to -> http://newsite.com/blog/archive RewriteRule ^(2012)$ https://newsite.com/blog/archive [R=301] </VirtualHost>
如果任何人都可以帮助,将不胜感激。
把“特殊”规则放在第一位 – 你可能需要RewriteCond 。 另外 – 你真的需要考虑不发送Host头的客户端吗?
RewriteCond %{HTTP_HOST} !^newsite\.com$ [NC] RewriteRule ^/2012$ https://newsite.com/blog/archive [R=301,L] RewriteCond %{HTTP_HOST} !^newsite\.com$ [NC] RewriteRule ^/(.*)$ http://newsite.com/$1 [R=301,L]