首页 > 解决方案 > 禁用除服务器块之外的目录访问

问题描述

我的 nginx 服务器块

server {
listen     80;
root /var/www/html/blog;
index index.php index.html index.htm;

运行 wordpress 的服务器。我想限制 PHP 仅访问 /var/www/html/blog。访问 /var/www/html/web 等其他目录的请求将被阻止。

我试过的-

location ~ ^/(?!(blog)/?) { 
    deny all;
    access_log off;
    log_not_found off;
}

怎么做?

标签: nginxnginx-confignginx-location

解决方案


推荐阅读