will request_uri get passed from cookieless server to 403 page on main server?

Francis Daly francis at daoine.org
Mon Nov 18 23:26:59 UTC 2013

On Sun, Nov 17, 2013 at 07:21:02PM -0500, Ian Evans wrote:
> On 17/11/2013 3:16 PM, Ian M. Evans wrote:

Hi there,

> >In my current setup, 403 errors are sent to a php file which grabs the
> >$_SERVER["REQUEST_URI"], locates the page of the photo on the site, and
> >redirects the person to that page so they see it in our context.

So when a 403 would be generated, you intercept it, do some processing,
and return an appropriate 302 instead.

> >So now I'm going to set up static.example.com.
> >
> >If I set the 403 error page to go to
> >error_page 403 http://www.example.com/dhe403.shtml;
> >
> >in order to run the PHP on the 403 error, does the REQUEST_URI get passed
> >between servers or do I have to do some rewrite magic that I currently
> >don't do?

No, it doesn't.

That directive says "instead of sending a 403, send a 302 for this other
url". What the browser does with that, is up to the browser.

> Just trying to think this through on my own...is it possible to pass the 
> request_uri as a variable to the error page on the new server?

> error_page 403 http://www.example.com/dhe403.shtml?req=$request_uri;

You can try. You may have to take care about url escaping, though.

(You can possibly avoid that if you use something like
.../dhe403.shtml/$request_uri and handle it appropriately on the far

It would seem easier to either proxy_pass or fastcgi_pass to the old
server, in an error_page 403 location on the new server, if you're happy
to have that level of not-just-static involved (and not happy to run
the full php suite on the new server).

That way, the browser would get one redirect to the intended destination
instead of one to an intermediate location first.

Francis Daly        francis at daoine.org

More information about the nginx mailing list