开发者

htaccess mod_rewrite: Redirect all subdomains, exclude some

开发者 https://www.devze.com 2023-02-04 14:18 出处:网络
There are many similar questions, but I couldn\'t find an answer to this specific one: In my .htaccess I have a rewrite to redirect all subdomains to http://example.com:

There are many similar questions, but I couldn't find an answer to this specific one:

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]
开发者_运维知识库

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消