nginx报错:access forbidden by rule

目录 文章

Nignx / PHP环境,访问站点提示报错access forbidden by rule

检查nginx配置文件,找到如下内容注释掉

       ##
       #注释
       #location ~ ^.+\.php {
       #         deny all;  #这里引起的
       #        }

完整配置文件示例如下:

server 
     {
        listen      80;
        server_name khh2.com;
        root   /home/wwwroot/khh2/admin/www/;
        access_log  /var/log/nginx/khh2/admin.access.log;
        error_log  /var/log/nginx/khh2/admin.error.log;
 
location / {
index  index.html index.htm index.php;
       if (!-e $request_filename) {
       rewrite ^/(.*)$ /index.php$1 last;
       break;
       }
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   unix:/tmp/php-cgi.sock;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;   
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
			include        fastcgi.conf;   
        }
 
		
       ##
       #注释:
       #location ~ ^.+\.php {
       #         deny all;  
       #        }
}
location ~ ^/(image|javascript|css|flash|media|static|jpeg|png|js)/ {
    expires 1h;
}		
>>本文为下一朵云的原创文章,转载请附上原文出处链接及本声明
>>原文链接地址:nginx报错:access forbidden by rule

暂无评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注