htaccess的mod_rewrite的:重定向所有子域,排除一些 [英] htaccess mod_rewrite: Redirect all subdomains, exclude some
本文介绍了htaccess的mod_rewrite的:重定向所有子域,排除一些的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有很多类似的问题,但我无法找到一个答案,这个特定的一个:
There are many similar questions, but I couldn't find an answer to this specific one:
在我的.htaccess我有一个重写重定向所有子域 http://example.com :
In my .htaccess I have a rewrite to redirect all subdomains to http://example.com:
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
但我想它忽略dev.example.com(也许一些其他的子域)。我想这是很容易,但我不明白。
But I want it to ignore dev.example.com (and maybe some other subdomains). I guess that's easy, but I can't figure it out.
推荐答案
为您排除主域名相同的:
Same way as you excluded the main domain:
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^dev\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
这篇关于htaccess的mod_rewrite的:重定向所有子域,排除一些的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文