在排除某些重定向子文件夹和域 [英] Exclude certain subfolders and domains in redirects

查看:199
本文介绍了在排除某些重定向子文件夹和域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是从<一个延续href=\"http://stackoverflow.com/questions/1704845/redirect-only-html-files\">http://stackoverflow.com/questions/1704845/redirect-only-html-files

我怎样才能改变我的的.htaccess 使它排除某些子文件夹或子域从只HTML重定向?使用这种code排除下载子文件夹和开发和支持的子域我试图做的,但它没有工作:

 的RewriteCond%{HTTP_HOST} ^ $ pandamonia.us [OR]
的RewriteCond%{HTTP_HOST} ^ $ www.pandamonia.us [OR]
的RewriteCond%{HTTP_HOST}!下载[OR]
的RewriteCond%{HTTP_HOST}!常见问题解答
的RewriteCond%{HTTP_HOST}!支持[OR]
重写规则/.+\\.html$HTTP \\:\\ / \\ / pandamonia \\页面没有自动跳转\\ /[L]


解决方案

您需要检查的 REQUEST_URI 的或在整场比赛重写规则 $ 1,0 此;的 HTTP_HOST 的也只包含当前请求的主机名。你还需要改变你的病情的逻辑前pression:

 的RewriteCond%{HTTP_HOST} ^ pandamonia \\ $页面没有自动跳转[OR]
的RewriteCond%{HTTP_HOST} ^ www.pandamonia \\ $页面没有自动跳转
的RewriteCond%{REQUEST_URI}!^ /下载/
的RewriteCond%{REQUEST_URI}!^ / FAQ /
的RewriteCond%{REQUEST_URI}!^ /支/
重写规则/.+\\.html$ http://pandamonia.us/ [L]

This is a continuation from http://stackoverflow.com/questions/1704845/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]

解决方案

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:

RewriteCond %{HTTP_HOST} ^pandamonia\.us$ [OR]
RewriteCond %{HTTP_HOST} ^www.pandamonia\.us$
RewriteCond %{REQUEST_URI} !^/download/
RewriteCond %{REQUEST_URI} !^/faq/
RewriteCond %{REQUEST_URI} !^/support/
RewriteRule /.+\.html$ http://pandamonia.us/ [L]

这篇关于在排除某些重定向子文件夹和域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆