自行更新伪静态,目前暂时不需要插件和主题伪静态,砍掉了,有需要的自行加上但需要限制运行权限。
注意替换路径,由 alias 改为了 root 避免嵌套
# WellCMS 3.0 Nginx 配置参考
# ⚠️ 重要提示:请将下方所有 /www/wwwroot/wellcms/ 路径替换为你服务器的实际部署路径!
server {
listen 80;
server_name your-domain.com;
# ⚠️ 修改此处为你服务器的实际站点根目录(必须指向 public/ 目录)
root /www/wwwroot/wellcms/public;
index index.php index.html;
# ------------------------------------------------------------------------
# 1) 视图静态资源(CSS/JS/图片/字体等)
# ------------------------------------------------------------------------
location ^~ /views/ {
# ⚠️ 修改为你的实际部署路径
root /www/wwwroot/wellcms/app;
# 禁止直接访问 .htm 模板(暴露页面结构)
location ~ \.htm$ { deny all; }
access_log off;
expires 30d;
}
# ------------------------------------------------------------------------
# 2) 上传文件静态资源
# ------------------------------------------------------------------------
location ^~ /upload/ {
# ⚠️ 修改为你的实际部署路径
root /www/wwwroot/wellcms/storage;
# 禁止执行 PHP(防插件解压目录 RCE)
location ~ \.php$ { deny all; }
# 禁止直接访问 HTML(防上传 HTML 引发的同源 XSS)
location ~ \.html$ { deny all; }
access_log off;
expires 30d;
}
# ------------------------------------------------------------------------
# 3) 程序静态资源(runtime 打包 JS/CSS 等)
# ------------------------------------------------------------------------
location ^~ /static/ {
# ⚠️ 修改为你的实际部署路径
root /www/wwwroot/wellcms/public;
# 纵深防御:禁止 PHP 执行
location ~ \.php$ { deny all; }
access_log off;
expires 30d;
}
# ------------------------------------------------------------------------
# 4) 伪静态规则(兼容 3 种 URL 风格,不推荐0和1,整个程序围绕3和4链接形式开发)
# user-login.html | /user/login.html | /user/login
# ------------------------------------------------------------------------
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ /\.ht {
deny all;
}
}