# Help with code

**URL:** <https://www.ruby-forum.com/t/help-with-code/235884>\
**Category:** NGINX\
**Created:** [July 22, 2013, 5:39pm UTC](https://www.ruby-forum.com/t/help-with-code/235884 "2013-07-22T17:39:37Z")\
**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:** [July 22, 2013, 5:39pm UTC](https://www.ruby-forum.com/t/help-with-code/235884/1 "2013-07-22T17:39:37Z")

</div>

Hi All,

I have the following code:

```
            location = /favicon.ico {
                    if ($host = "abc.com"){
                        return 301 "http://www.abc.com/favicon.ico";
                    }
            }

```

If I make a request to [abc.com/favicon.ico](http://abc.com/favicon.ico) I get a 301 and then a 200 OK

However the issue is that if I make a request to [xyz.abc.com/favicon.ico](http://xyz.abc.com/favicon.ico)  
I get a 404 as it passes the first match statement but fails the second  
and trys to get the favicon resource from the nginx root directory

Is there a better way of doing it so it continues on to be evaluated by  
the other rules? or Is there a better way of writing this part of the  
code?

Thanks in advance.

Nick

---

<div class="post-metadata">

**Author:** ![ntran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/73ab20/32.png) [@ntran](https://www.ruby-forum.com/u/ntran)\
**Post date:** [July 22, 2013, 6:10pm UTC](https://www.ruby-forum.com/t/help-with-code/235884/2 "2013-07-22T18:10:36Z")

</div>

On 22.07.2013, at 17:39, Nick T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If I make a request to [abc.com/favicon.ico](http://abc.com/favicon.ico) I get a 301 and then a 200 OK
> 
> However the issue is that if I make a request to [xyz.abc.com/favicon.ico](http://xyz.abc.com/favicon.ico) I get a  
> 404 as it passes the first match statement but fails the second and trys to get  
> the favicon resource from the nginx root directory

Why should the check process even go inside the if, given that  
[xyz.abc.com](http://xyz.abc.com) is not host [abc.com](http://abc.com)?

Jan
