如何拒绝访问目录中的php文件? nginx的
发布时间:2020-12-13 13:56:17 所属栏目:PHP教程 来源:网络整理
导读:我已经尝试了很多配置的变种,但我仍然无法让它按预期工作.有什么建议? location ~ /views/(.+).php${ deny all; } 配置: server { listen 80; server_name ...; #charset koi8-r; #access_log logs/host.access.log main; location / { root /srv/www; in
|
我已经尝试了很多配置的变种,但我仍然无法让它按预期工作.有什么建议?
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${
.....
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
