我在根目录中有 2 个索引文件 (index.php、thanks.php),当用户请求其他位置时,我想使用 thanks.php,例如:当用户请求示例.comnginx 显示索引.php,但当用户请求example.com/thanksnginx 必须显示谢谢.php 我尝试了这个配置,但它对我来说不起作用:
server {
root /var/www/example.com;
index index.php;
server_name example.com www.example.com;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /thanks {
alias /var/www/example.com;
index thanks.php;
}
}