35互联虚拟主机静态资源403_chmod与index配置
静态资源403 时分清是服务器 403 还是 CDN/WAF 403。服务器 403 页面有 Nginx/Apache 标识,CDN 403 页面有 CDN 标识。CDN 403 通常是 WAF 规则拦截或防盗链,服务器 403 是权限或配置问题。用 curl -x 127.0.0.1:80 测源站,区分层级。
deny 规则排查:Apache 的 .htaccess 里有 Deny from all 或 Order Deny,Allow 配置错误;Nginx 的 server/location 里有 deny all;IIS 的 web.config 里有 ipSecurity 或 authorization 规则。注释掉可疑规则测试,找到触发 403 的规则后修正。防盗链规则误杀自己域名的,把自己域名加进白名单。
参考(403权限修复命令): ``` # 查看权限和属主 ls -la /www/wwwroot/域名 ls -la /www/wwwroot/域名/index.php
# 批量修复权限 find /www/wwwroot/域名 -type d -exec chmod 755 {} ; find /www/wwwroot/域名 -type f -exec chmod 644 {} ;
# 修复属主(Nginx) chown -R www:www /www/wwwroot/域名 # Apache chown -R apache:apache /www/wwwroot/域名 # 写入目录给775 chmod 775 /www/wwwroot/域名/upload chown www:www /www/wwwroot/域名/upload
# Nginx错误日志 tail -50 /var/log/nginx/error.log # Apache错误日志 tail -50 /var/log/httpd/error_log
# 测试源站(绕过CDN) curl -I -x 127.0.0.1:80 http://域名/ ```
预防 403:权限规范化(目录 755 文件 644)、默认首页必传、修改配置前备份、防盗链白名单包含所有绑定域名、定期检查访问日志的 403 状态码。403 占比超过 5% 就要排查原因,正常站点 403 占比在 1% 以下。
Apache 403 专项:Apache 错误日志在 /var/log/httpd/error_log 或 /var/log/apache2/error.log,常见 "client denied by server configuration"(deny 规则或 Options)、"Permission denied"(文件系统权限)。.htaccess 语法错误会导致 500 不是 403,注意区分。

更新时间:2026-08-26 23:20:37
上一篇:美橙互联 Java 主机Resin部署SSL证书动态地址 301 到伪静态地址完整教程_首选域集中权重