你可以尝试这个 server { # 其他服务器配置... location ~ /(app|config|data|logs|vendor) { deny all; return 403; } location ~* \.(env|example|lock|md|sql)$ { deny all; return 403; } location = /index.php { # 用于处理PHP的配置(比如fastcgi_pass等)... # 仅当你的服务器配置了PHP处理时才需要 } location / { try_files $uri $uri/ /index.php?$query_string; } # 其他location或配置... }