现有配置如下,想增加 config.js -> 重写到 config.php 且不允许直接访问config.php,怎么搞哦,谢谢哈。。。
server { listen 80;
server_name js.mydomain.com;
charset utf-8;
set $root '/dat/www/js.mydomain.com/public';
root $root;
add_header Cache-Control no-cache;
add_header Cache-Control private;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite ;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root $root;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
rewrite ^/config.js /config.php;
location ~ /config.php {
internal;
fastcgi_pass xxx;
....
}
关键是要用internal, 禁止直接访问。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。