重定向选择路径到不同域时出现问题



我在我的。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

此规则适用于urlSecure.x.com/en/noaccount =>重定向到x.com/en/noaccount

但不适合请求secure.x.com/en/account

这个规则有什么问题?

我找到了解决问题的方法。我不知道这是否是最优的解决方案,但它有效。

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 .

最新更新