小弟配置 Nginx 力求簡(jiǎn)單明了盈魁,禁止直接調(diào)用 .php 文件窗骑,杜絕安全隱患翩迈,同時(shí)允許讀取靜態(tài)資源文件膘流。
server
{
listen 80;
server_name thinkphp.com;
index index.html index.htm index.php;
root /usr/local/web/thinkphp/public;
# 禁止讀取 svn 文件
location ~ ^(.*)\/\.svn\/
{
return 404;
}
# 禁止允許 .php 文件
location ~ \.php
{
return 444;
}
# 允許訪問靜態(tài)資源
location ~ (/static/)|(favicon\.ico$)
{
try_files $uri =404;
}
location /
{
# try_files $uri /index.php?$query_string;
rewrite ^/(.*)$ /index.php?s=/$1;
location = /index.php
{
# 開啟 PATH_INFO
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}
引用:
簡(jiǎn)單配置nginx使之支持pathinfo
老朱親自寫的,最完美ThinkPHP Nginx 配置文件
thinkphp5 的 nginx 配置文件
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者