server {
listen 80;
listen [::]:80;
server_name _;
root /var/www/html/xxx;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
index index.php index.html index.htm;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
}
nginx.conf配置如下内容
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}

该博客主要介绍了 Nginx 配置文件中关于监听端口、服务器名称、根目录设置以及 URL 重写规则的使用。在location块内,当请求的文件不存在时,会将请求重定向到 index.php,并传递参数。此配置适用于基于 PHP 的Web应用,确保了对静态文件和服务端脚本的正确处理。
1021

被折叠的 条评论
为什么被折叠?



