我知道这是一个受欢迎的问题,但我还没有发现任何人有类似的问题。只要 .php 扩展名不在 url 中,我就可以提供 PHP 文件。例如:
如果我去,我会得到localhost我的 index.php 文件。如果我去localhost/index.php我下载文件。这是我的配置:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used …Run Code Online (Sandbox Code Playgroud)