Rewrite new url and block old url in nginx

Posted by Howard on Server Fault See other posts from Server Fault or by Howard
Published on 2012-11-24T10:02:55Z Indexed on 2012/11/24 11:11 UTC
Read the original article Hit count: 153

Filed under:
|

I have a local folder /bar, and I want to be able access via http://www.example.com/foo.

So I have the config like

rewrite  ^/foo/(.*)$ /bar/$1 last;

At the same time, I want to block public access to the real url /bar,

Then I add the config like

location ~* ^/bar{ return 404; }

But when I add this url into the config, the 1st config above not work, now both return 404

Anything I should fix in order to make the rewrite work?

Thanks.

© Server Fault or respective owner

Related posts about nginx

Related posts about rewrite