gpt4 book ai didi

Nginx:设置默认文件扩展名

转载 作者:行者123 更新时间:2023-12-05 00:02:37 28 4
gpt4 key购买 nike

我会为 nginx 使用什么规则,所以我的默认文件扩展名是 .php?

我目前使用 www.mywebsite.com/ 访问页面home.php 但我只想使用 www.mywebsite.com/首页

谢谢

最佳答案

假设您还想提供静态文件,您可以使用以下内容:

server {
server_name example.com;

# Set the docroot directly in the server
root /var/www;

# Allow index.php or index.html as directory index files
index index.html index.php;

# See if a file or directory was requested first. If not, try the request as a php file.
location / {
try_files $uri $uri/ $uri.php?$args;
}

location ~ \.php$ {
# If the php file doesn't exist, don't pass the request to php, just return a 404
try_files $uri =404;

include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;

fastcgi_pass your_php_backend_address;
}
}

关于Nginx:设置默认文件扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7760883/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com