![](/img/trans.png)
[英]How to redirect all URLs except one path and all its subpaths without mod_rewrite?
[英]mod rewrite to redirect all except the root
因此,如果有人登陆SomeFunnyWebsite.com,我将拥有SomeFunnyWebsite.com和ActualSite.com,我希望他们看到有趣的图片,但是如果他们转到SomeFunnyWebsite.com/AnyThing,我需要它以301重定向到ActualSite.com
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://actualsite.com/$1 [R=301,L,QSA]
但这不会重定向到任何东西。 但我已经证实其他重定向规则也可以使用。
尝试使用重写条件,使特定域的/
上的匹配项反转。
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{HTTP_HOST} ^(www\.)?somefunnywebsite\.com$ [NC]
RewriteRule ^.*$ http://actualsite.com%{REQUEST_URI} [R=301,L,QSA]
我还没有测试过,但这应该可以帮助您入门。 (我建议使用302来启动,因为浏览器倾向于缓存301重定向。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.