在重定向中排除某些子文件夹和域
这是仅重定向 HTML 文件?的延续,
如何更改我的 .htaccess
使其从纯 HTML 重定向中排除某些子文件夹或子域?我尝试使用此代码排除“downloads”子文件夹以及“dev”和“support”子域,但它不起作用:
RewriteCond %{HTTP_HOST} ^pandamonia.us$ [OR]
RewriteCond %{HTTP_HOST} ^www.pandamonia.us$ [OR]
RewriteCond %{HTTP_HOST} !download [OR]
RewriteCond %{HTTP_HOST} !faq
RewriteCond %{HTTP_HOST} !support [OR]
RewriteRule /.+\.html$ "http\:\/\/pandamonia\.us\/" [L]
This is a continuation from Redirect only HTML files?
How can I change my .htaccess
to make it exclude certain subfolders or subdomains from the HTML-only redirect? I tried doing using this code to exclude the 'downloads' subfolder and the 'dev' and 'support' subdomains, but it didn't work:
RewriteCond %{HTTP_HOST} ^pandamonia.us$ [OR]
RewriteCond %{HTTP_HOST} ^www.pandamonia.us$ [OR]
RewriteCond %{HTTP_HOST} !download [OR]
RewriteCond %{HTTP_HOST} !faq
RewriteCond %{HTTP_HOST} !support [OR]
RewriteRule /.+\.html$ "http\:\/\/pandamonia\.us\/" [L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,您需要检查 REQUEST_URI 或
RewriteRule
$0
的整个匹配项; HTTP_HOST 仅包含当前请求的主机名。您还需要更改条件的逻辑表达式:You need to check REQUEST_URI or the whole match of the
RewriteRule
$0
for this; HTTP_HOST does only contain the host name of the current request. You also need to change the logical expression of your condition:对于那些想要快速了解 Gumbo 之前的回复的人(他提到了何时(或不)使用的情况[OR]),我发现这个 WMW 线程非常有帮助:http://www.webmasterworld.com/apache/3522649.htm
For those looking for a quick bit of insight into Gumbo's previous reply (where he mentions the situations for when to (and not to) use [OR], I found this WMW thread very helpful: http://www.webmasterworld.com/apache/3522649.htm