Nginx 泛域名配置范例
server {
listen 80;
server_name *.szher.com szher.com;
root /www/wwwroot/szher.com;
index index.php index.html;
# 静态资源缓存配置
location ~* .(jpg|jpeg|gif|png|css|js|ico|woff2)$ {
expires 30d;
access_log off;
}
# 核心伪静态重写规则
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP-FPM 处理
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}配置保存后执行 nginx -t 确认语法无误,再执行 nginx -s reload 即可生效。