# Sub-domain filtering

**URL:** <https://www.ruby-forum.com/t/sub-domain-filtering/236258>\
**Category:** NGINX\
**Created:** [August 19, 2013, 8:05am UTC](https://www.ruby-forum.com/t/sub-domain-filtering/236258 "2013-08-19T08:05:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 19, 2013, 8:05am UTC](https://www.ruby-forum.com/t/sub-domain-filtering/236258/1 "2013-08-19T08:05:44Z")

</div>

I am using the statement is:  
if ($ host! = [www.mj.com|ci.mj.com](http://www.mj.com%7Cci.mj.com)) {rewrite ^ / (. \*) $  
[http://www.mj.com/](http://www.mj.com/)  
$ 1 permanent;}  
This page contains a redirect loop occurs causing the problem can not  
access  
the site, I ask you how to handle this statement to be compatible with  
multiple subdomains, thank you

Posted at Nginx Forum:

> **[Sub-domain filtering](https://forum.nginx.org/read.php?2,242007,242007#msg-242007)**
>
> I am using the statement is: if ($ host! = www.mj.com|ci.mj.com) {rewrite ^ / (. \*) $ http://www.mj.com/ $ 1 permanent;} This page contains a redirect loop occurs causing the problem can not access the site, I ask you how to handle this statement to...

---

<div class="post-metadata">

**Author:** ![ronin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ad7895/32.png) [@ronin](https://www.ruby-forum.com/u/ronin)\
**Post date:** [August 19, 2013, 9:14am UTC](https://www.ruby-forum.com/t/sub-domain-filtering/236258/2 "2013-08-19T09:14:05Z")

</div>

On 19 Aug 2013 07:05, “ronin” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am using the statement is:  
> if ($ host! = [www.mj.com|ci.mj.com](http://www.mj.com%7Cci.mj.com)) {rewrite ^ / (. \*) $  
> [http://www.mj.com/](http://www.mj.com/)  
> $ 1 permanent;}  
> This page contains a redirect loop occurs causing the problem can not  
> access  
> the site, I ask you how to handle this statement to be compatible with  
> multiple subdomains, thank you

Use a separate server{} for the redirection-only vhosts.

J
