2011-09-20 51 views
0

我在我的.htaccess文件中有這條規則我想獲得的是重定向所有 請求不匹配secure.x.com/en/account?x=1x.com/en/account?x=1和所有請求,如secure.x.com/en/account/xxxx不應重定向。問題與重定向選擇路徑到不同的域

Options Indexes FollowSymLinks 
RewriteEngine On 

RewriteCond %{HTTP_HOST} secure.x.com [NC] 
RewriteCond %{REQUEST_URI} !^[a-z-]{2,8}/account [NC] 
RewriteRule (.*) http://x.com%{REQUEST_URI} [R=301,L] 

RewriteRule !\.(css|gif|htm|html|ico|jpg|js|pdf|php|png|swf|txt|xml)$ index.php 

此規則正常工作對URL像 secure.x.com/en/noaccount =>重定向到x.com/en/noaccount

但不要求如 secure.x.com/en/account

該規則的問題是什麼?

回答

0

我找到了我的問題的解決方案。我不知道這是否是最佳解決方案,但它的工作原理。

Options Indexes FollowSymLinks 
RewriteEngine On 

RewriteCond %{ENV:REDIRECT_STATUS} 200 
RewriteRule .* - [S=3] 

RewriteCond %{HTTP_HOST} local.secure.x.com [NC] 
RewriteCond %{REQUEST_URI} ![a-z]{2,8}/account [NC] 
RewriteRule ^(.*)$ http://local.x.com/$1 [R=301,L] 

RewriteRule !\.(css|gif|htm|html|ico|jpg|js|pdf|php|png|swf|txt|xml)$ index.php 

如果有人有更好的主意讓我知道。 TNX。