脚本宝典收集整理的这篇文章主要介绍了如何拒绝访问目录中的php文件? nginx的,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
location ~ /views/(.+)\.PHP${ deny all; }
配置:
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${ # root html; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.PHP; fastcgi_param SCRIPT_FILENAME /srv/www$fastcgi_SCRIPT_NAME; } if (!-e $request_filename){ rewrITe ^/([0-9]+)$/get.PHP?get=$1 last; rewrite ^/add$/add.PHP; rewrite ^/RSS$/RSS.PHP; } location ~ /views/(.+)\.PHP${ deny all; } }
交换位置(正则表达式按配置文件中定义的顺序检查):
location ~ /views/(.+)\.PHP${ deny all; } location ~ \.PHP${ .....
以上是脚本宝典为你收集整理的如何拒绝访问目录中的php文件? nginx的全部内容,希望文章能够帮你解决如何拒绝访问目录中的php文件? nginx的所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。