[英]How to redirect multiple domains to another domain except 1 directory using htaccess?
I am trying to redirect multiple domains to a single domain (which is working fine) but i want one directory to not redirect or change the main domain url.我正在尝试将多个域重定向到一个域(工作正常),但我希望一个目录不重定向或更改主域 url。
here is my .htaccess code it works fine until here这是我的 .htaccess 代码,它工作正常,直到这里
this one is working这个正在工作
<pre>
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.net$ [OR]
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.org$ [OR]
RewriteCond %{HTTP_HOST} ^domain.info$ [OR]
RewriteCond %{HTTP_HOST} !^www.domain.info
RewriteRule (.*) http://www.domain.info/$1 [R=301,L]
</pre>
but when i try to stop redirect of one specific directory by但是当我尝试通过以下方式停止重定向一个特定目录时
full code完整代码
<pre>
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.net$ [OR]
RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.org$ [OR]
RewriteCond %{HTTP_HOST} ^domain.info$ [OR]
RewriteCond %{HTTP_HOST} !^www.domain.info [OR]
RewriteCond %{REQUEST_URI} !^/no_redirect_dir/
RewriteRule (.*) http://www.domain.info/$1 [R=301,L]
</pre>
it all stops working :( with an error that page is not redirecting correctly.一切都停止工作:(出现错误,页面未正确重定向。
extra code causing error导致错误的额外代码
<pre>
RewriteCond %{HTTP_HOST} !^www.domain.info [OR]
RewriteCond %{REQUEST_URI} !^/no_redirect_dir/
</pre>
any help would be highly appreciated.任何帮助将不胜感激。
thank you!谢谢你!
Write your .htaccess like this:像这样写你的 .htaccess:
RewriteCond %{HTTP_HOST} (www\.)?domain\.(org|net|com)$ [NC]
RewriteCond %{REQUEST_URI} !^/*no_redirect_dir/ [NC]
RewriteRule ^(.*)$ http://www.domain.info/$1 [R=301,L]
HTTP_HOST variable just has domain name, no http/https information. HTTP_HOST 变量只有域名,没有 http/https 信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.