2013-09-23 43 views
5

我的實際htaccess的重定向我的完整的舊網站到我的新網站,我想重定向所有域名,但除了兩種文件.PHP(protectetfile1.php和protectedfile2.php)。的.htaccess重定向所有域,除了兩個文件

這是我的htaccess

RewriteEngine On 
Rewritecond %{http_host} ^olddomain.org [NC] 
Rewriterule ^(.*)$ http://newdomain.net/$1 [L,R=301] 

回答

11

使用此規則:

RewriteEngine On 
Rewritecond %{http_host} ^olddomain\.org [NC] 
RewriteCond %{REQUEST_URI} !/(protectetfile1|protectetfile2)\.php [NC] 
Rewriterule ^(.*)$ http://newdomain.net/$1 [L,R=301] 
+0

EXCELENT htaccess的,如果你想添加更多的文件,你可以不斷加入!| –

+0

是的,這是正確的,你可以把用管道符號(OR)更多的文件。 – anubhava

相關問題