Nginx index.php 仅禁止子目录!

Nginx index.php 仅禁止子目录!

我在 OpenVZ Container 上使用 nginx 1.0.4 + php-fpm + wordpress。我的设置运行正常。但是当我尝试访问http://example.com/wp-admin/它给了我 403 错误,我访问http://example.com/wp-admin/index.php工作正常。错误日志:

2011/07/24 21:50:38 [error] 29939#0: *35 "/home/example/blog/public_html/wp-admin/index.php" is forbidden (13: Permission denied), client: 125.234.x.x, server: loopback.info, request: "GET /wp-admin/ HTTP/1.1", host: "example.com"

以下是我的配置:

    upstream example {
            server    unix:/dev/shm/example.sock;

    server {
            listen   80;
            server_name  example.com;
            root /home/example/blog/public_html;
            index index.php;
            access_log  /home/example/blog/logs/access.log;
            error_log /home/example/blog/logs/error.log;

            location ~ /\.ht {
             deny all;
            }
            location = /favicon.ico {
                    log_not_found off;
                    access_log off;
            }

            location = /robots.txt {
                    allow all;
                    log_not_found off;
                    access_log off;
            }


            location / {
                    try_files $uri $uri/ /index.php;
            }

            location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass  example;
            include        fastcgi_params;
        }

     location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }

}

答案1

我通过删除解决了

 open_file_cache max=5000 inactive=20s;

来自主 nginx 配置文件。

相关内容