Nginx redirect all 403 to 404?

House3272 asked:

I’m trying to get 403 responses to be exactly identical to 404 ones.

Not sure if there’s a proper way to do it, but setting
error_page 403 404
is my current method.

Which works, but it rewrites the url to mysite.com/404 for 403’s
while regular 404’s leave the url alone.

Oh and I don’t have any 4XX custom pages set up and I deleted the default nginx one.

My answer:


The nginx documentation clearly says that if you want to change the response code, you use =response. For example:

error_page 403 =404;

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.