# Match all requests

**URL:** <https://www.ruby-forum.com/t/match-all-requests/213832>\
**Category:** NGINX\
**Created:** [November 13, 2011, 4:58pm UTC](https://www.ruby-forum.com/t/match-all-requests/213832 "2011-11-13T16:58:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [November 13, 2011, 4:58pm UTC](https://www.ruby-forum.com/t/match-all-requests/213832/1 "2011-11-13T16:58:36Z")

</div>

I have this location configuration:

```
    location /
    {
            index maintenance.htm;
            error_page 404 = maintenance.htm;
            log_not_found off;
    }

```

which I thought captures all requests, however, entering “/index.php”  
for  
example, causes the file to be downloaded instead of going to the  
“maintenance.htm” file. How can I capture all requests?

–

Ilan B.  
Chief Technology Officer

> **[Time4Learning.com](https://www.time4learning.com)**
>
> Award-winning online curriculum teaching math, language arts, science, social studies and more! Great for homeschool, afterschool & summer use.

6300 NE 1st Ave., Suite 203  
Ft. Lauderdale, FL 33334  
(954) 771-0914

[http://www.twitter.com/time4learning](http://www.twitter.com/time4learning)  
[http://www.facebook.com/Time4Learning](http://www.facebook.com/Time4Learning)

[Time4Learning.com](http://Time4Learning.com) - Online interactive curriculum for home use, PreK-8th  
Grade.  
[Time4Writing.com](http://Time4Writing.com) - Online writing tutorials for high, middle, and  
elementary school students.  
[Time4Learning.net](http://Time4Learning.net) - A forum to chat with parents online about kids,  
education, parenting and more.  
[spellingcity.com](http://spellingcity.com) - Online vocabulary and spelling activities for  
teachers,  
parents and students.

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [November 13, 2011, 5:31pm UTC](https://www.ruby-forum.com/t/match-all-requests/213832/2 "2011-11-13T17:31:32Z")

</div>

2011/11/13 Ilan B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> example, causes the file to be downloaded instead of going to the  
> “maintenance.htm” file. How can I capture all requests?

Maybe if you put like this before the other locations:

location ~ .\*$  
{  
index maintenance.htm;  
error\_page 404 = maintenance.htm;  
log\_not\_found off;  
}

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [November 13, 2011, 5:33pm UTC](https://www.ruby-forum.com/t/match-all-requests/213832/3 "2011-11-13T17:33:24Z")

</div>

On Sunday 13 November 2011 19:57:53 Ilan B. wrote:

> I have this location configuration:
> 
> ```
> location /
> {
> 
> ```

This:

> ```
> index maintenance.htm;
> 
> ```

only captures requests to directories (i.e., ends with a /).

This:

> ```
> error_page 404 = maintenance.htm;
> 
> ```

only captures 404 responses.

> ```
> log_not_found off;
> }
> 
> ```
> 
> which I thought captures all requests, however, entering “/index.php” for  
> example, causes the file to be downloaded instead of going to the  
> “maintenance.htm” file. How can I capture all requests?

Probably, you want something like this:

error\_page 404 = /maintenance.htm;

location / {  
return 404;  
}

location = /maintenance.htm {}

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [November 13, 2011, 10:39pm UTC](https://www.ruby-forum.com/t/match-all-requests/213832/4 "2011-11-13T22:39:16Z")

</div>

Igor,

Thanks, but the code you provided still causes the  
[domain.com/index.phpfile](http://domain.com/index.phpfile) to be downloaded instead of the maintenance  
page to show up?

On Sun, Nov 13, 2011 at 11:44 AM, Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > which I thought captures all requests, however, entering “/index.php” for
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–

Ilan B.  
Chief Technology Officer

> **[Online Homeschool Curriculum from Time4Learning](https://www.time4learning.com/)**
>
> PreK-12 homeschooling is EASY with Time4Learning at your fingertips with award-winning online lessons, and parent-friendly planning and reporting tools.

6300 NE 1st Ave., Suite 203  
Ft. Lauderdale, FL 33334  
(954) 771-0914

[http://www.twitter.com/time4learning](http://www.twitter.com/time4learning)  
[http://www.facebook.com/Time4Learning](http://www.facebook.com/Time4Learning)

[Time4Learning.com](http://Time4Learning.com) - Online interactive curriculum for home use, PreK-8th  
Grade.  
[Time4Writing.com](http://Time4Writing.com) - Online writing tutorials for high, middle, and  
elementary school students.  
[Time4Learning.net](http://Time4Learning.net) - A forum to chat with parents online about kids,  
education, parenting and more.  
[spellingcity.com](http://spellingcity.com) - Online vocabulary and spelling activities for  
teachers,  
parents and students.

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [November 13, 2011, 10:48pm UTC](https://www.ruby-forum.com/t/match-all-requests/213832/5 "2011-11-13T22:48:34Z")

</div>

On 13.11.2011 22:38, Ilan B. wrote:

> Thanks, but the code you provided still causes the  
> [domain.com/index.phpfile](http://domain.com/index.phpfile) to be downloaded instead of the maintenance  
> page to show up?

Because you use location .php$ for php, I presume so you need add there  
something like 'try\_files /maintenance.htm $uri =404;

There = to the php’s location block.

You may need read [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpCoreModule#location)

– Piotr.

---

<div class="post-metadata">

**Author:** ![iberci](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/a3d4f5/32.png) [@iberci](https://www.ruby-forum.com/u/iberci)\
**Post date:** [November 13, 2011, 5:44pm UTC](https://www.ruby-forum.com/t/match-all-requests/213832/6 "2011-11-13T17:44:31Z")

</div>

On Sun, Nov 13, 2011 at 10:57:53AM -0500, Ilan B. wrote:

> example, causes the file to be downloaded instead of going to the  
> “maintenance.htm” file. How can I capture all requests?

location / {  
try\_files /maintenance.htm =404;  
}

–  
Igor S.
