首页 > nginx如何设置不可访问某一个目录

nginx如何设置不可访问某一个目录

我写了个url rewrite,结构:

http://xxx.com/abc -> index.php/abc
http://xxx.com/abc/bcd -> index.php/abc/bcd

根目录下因为特殊原因必须存在abc/目录,这时候出问题了,访问http://xxx.com/abc直接访问的是这个目录而不是url rewrite,但是我希望反过来。优先访问rewrite,而不是目录。同时还有个需求就是仅限这个目录是这样,其他目录还是优先访问目录,然后才是rewrite

rewrite我是这么写的:

if (!-e $request_filename){
    rewrite ^/(.*)$ /index.php?/$1;
}

location /xxx {
 deny all;
 return 403;
}

xxx为目录名

【热门文章】
【热门文章】