# Re: Change error page by file type?

**URL:** <https://www.ruby-forum.com/t/re-change-error-page-by-file-type/137805>\
**Category:** NGINX\
**Created:** [May 16, 2008, 3:25pm UTC](https://www.ruby-forum.com/t/re-change-error-page-by-file-type/137805 "2008-05-16T15:25:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rt\_Ibmer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@Rt\_Ibmer](https://www.ruby-forum.com/u/Rt_Ibmer)\
**Post date:** [May 16, 2008, 3:25pm UTC](https://www.ruby-forum.com/t/re-change-error-page-by-file-type/137805/1 "2008-05-16T15:25:06Z")

</div>

Yes, however due to the complexity of our configuration (which includes  
many location blocks with several proxy\_pass blocks inside), I am trying  
to avoid duplicating location blocks for this purpose.

I found something promising, however. According to the docs the the  
error\_log directive is supported “if in location” as a context which it  
can be used in. Therefore I am thinking I can just add a group of if  
statements with regex checking inside of one location block and use the  
“if” block to set up the error\_logs. I’ll give this a try.

----- Original Message ----  
From: Roxis [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: removed\_email\_address@domain.invalid  
Sent: Friday, May 16, 2008 4:06:18 AM  
Subject: Re: Change error page by file type?

On Friday 16 May 2008, Roxis wrote:

> > > If someone makes a request for a .js file from our server and no such  
> > > }

- location ~ /something/.+.js {

- location ~ ^/something/.+.js$ {

> ```
> #config for location /something/
> error_page 404 /errors/error.js;
> 
> ```
> 
> }

- location ~ /something/.+.htm {

- location ~ ^/something/.+.htm$ {
