WordPress更改“固定链接”后 页面404原因及解决方法

Nginx 解决方案:

在nginx 对应的主机配置文件的 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; }

重新载入nginx:

service nginx restart

Apache解决方案:

原因一:Apache中的rewrite模块没有开启,去除这一行前面的#号就可以了

LoadModule rewrite_module modules/mod_rewrite.so

原因二:AllowOverride Not Enabled;服务器可能没打开AllowOverride。如果httpd.config的AllowOverride设置的是None,那.htaccess将被忽略。找到以下2处位置并修改:

<Directory /> Options FollowSymLinks AllowOverride All </Directory>
<Directory /var/www/html> # … other directives… AllowOverride All </Directory>

修改完成后,要重启Apache才能生效。

service httpd restart

腾讯云限时秒杀【点击购买】

搬瓦工,CN2高速线路,1GB带宽,电信联通优化KVM,延迟低,速度快,建站稳定,搬瓦工BandwagonHost VPS优惠码BWH26FXH3HIQ,支持<支付宝> 【点击购买】!

Vultr$3.5日本节点,512M内存/500G流量/1G带宽,电信联通优化,延迟低,速度快【点击购买】!

阿里云香港、新加坡VPS/1核/1G/25G SSD/1T流量/30M带宽/年付¥288【点击购买】