wordpress 固定链接 页面404错误的解决方法 绝地灬酷狼 2022-02-02 19:17 231阅读 0赞 ## wordpress设置“固定链接”后,页面404错误的解决方法 ## ## Nginx 解决方案: ## loction / \{\}中添加配置: \#加入如下一条命令即可 try\_files $uri u r i / / i n d e x . p h p ? uri/ /index.php? uri//index.php?args; 修改完成后重启Nginx服务器生效。 #解决固定连接404 location / { try_files $uri $uri/ /index.php?$args; } # 重启nginx service nginx restart 完整代码 server { listen 80; server_name zhaoyang.space; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/zhaoyang.space; #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 #error_page 404/404.html; #SSL-END #ERROR-PAGE-START 错误页配置,可以注释、删除或修改 error_page 404 /404.html; error_page 502 /502.html; #ERROR-PAGE-END #PHP-INFO-START PHP引用配置,可以注释或修改 include enable-php-56.conf; #PHP-INFO-END #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效 include /www/server/panel/vhost/rewrite/zhaoyang.space.conf; #REWRITE-END location / { try_files $uri $uri/ /index.php?$args; } #禁止访问的文件或目录 location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) { return 404; } #一键申请SSL证书验证目录相关设置 location ~ \.well-known{ allow all; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; error_log off; access_log /dev/null; } location ~ .*\.(js|css)?$ { expires 12h; error_log off; access_log /dev/null; } access_log /www/wwwlogs/zhaoyang.space.log; error_log /www/wwwlogs/zhaoyang.space.error.log; } 网上盛传的方法是: 在 /etc/nginx/nginx.conf文件的 loction / \{\} 中添加 if (-f $request\_filename/index.html)\{ rewrite (.\*) $1/index.html break; \} if (-f $request\_filename/index.php)\{ rewrite (.\*) $1/index.php; \} if (!-f $request\_filename)\{ rewrite (.\*) /index.php; \} 特别注意:这种设置方法无效,无效,无效。 1.2.2 Apache解决方案: /etc/httpd/conf/httpd.config 文件 原因一:Apache中的rewrite模块没有开启,去除这一行前面的\#号就可以了 LoadModule rewrite\_module modules/mod\_rewrite.so 原因二:AllowOverride Not Enabled;服务器可能没打开AllowOverride。如果httpd.config的AllowOverride设置的是None,那.htaccess将被忽略。找到以下2处位置并修改: Options FollowSymLinks AllowOverride All service httpd restart
还没有评论,来说两句吧...