小编Bud*_*ddy的帖子

如何拒绝访问目录中的php文件?nginx

我已经尝试了很多配置的变体,但我仍然无法让它正常工作。有什么建议?

 location ~ /views/(.+)\.php$ {
      deny all;
 }
Run Code Online (Sandbox Code Playgroud)

配置:

server {
    listen       80;
    server_name  ...;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /srv/www;
        index  index.php index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ { …
Run Code Online (Sandbox Code Playgroud)

nginx

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

nginx ×1