.htaccess,重定向网站但有例外

时间:2014-10-20 20:50:32

标签: php wordpress .htaccess

我正在重定向整个网站,但有一些例外。我有以下规则和条件:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

#RewriteCond %{HTTP_HOST} !^loans\.myoldwebsite\.com$ [NC]
#RewriteCond %{HTTP_HOST} !^client\.myoldwebsite\.com$ [NC]
#RewriteRule ^(.*)$ https://www.mynewwebsite.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} !^(client|loans)\.myoldwebsite\.com$ [NC]
RewriteRule ^(.*)$ https://www.mynewwebsite.com/$1 [L,NE,R=302]

但我还需要确保http://www.myoldwebsite.com/getLead.php也被忽略,因此它不会被重定向。

1 个答案:

答案 0 :(得分:0)

您可以拥有多个RewriteCond

RewriteCond %{HTTP_HOST} !^(client|loans)\.myoldwebsite\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/getLead.php$
RewriteRule ^(.*)$ https://www.mynewwebsite.com/$1 [L,NE,R=302]