我想将www.example.com/this/或example.com/this/redirect到.example.com
目前在我的.htaccess文件中,我有:
RewriteEngine on RewriteCond ${HTTP_HOST} ^(www\.)?example\.com/this$ RewriteRule ^(.*) http://that.example.com/$1 [R=301,L]
然而,这不适合我。
Apache的mod_alias redirect更简单,你可以尝试这样的事情:
Redirect /this http://that.example.com/
%HTTP_HOST只会匹配主机名(www.example.com)。 您还需要在%REQUEST_URI上匹配,然后使用它插入到规则中
RewriteCond %{REQUEST_URI} !^/(.*)$