SmallBrother avatar

wordpress迁移/更换服务器后固定链接404错误

laosan

Published: 01 Dec 2017 › Updated: 01 Dec 2017

wordpress迁移/更换服务器后固定链接404错误

症状
  • 迁移/更换服务器后,wordpress站点首页正常;
  • 若固定链接格式为默认格式,自定义就404错误;
Nginx

在网站的Nginx配置文件的{ }位置之间添加如下代码,并重启Nginx

location / {
 try_files $uri $uri/ /index.php?q=$uri&$args;
}
Apache或litespeed

进入网站文件夹,编辑.htaccess,添加/编辑如下代码,并重启apache或litespeed

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
RewriteRule ^/index\.php$ - [L]   # 就是在^ index\.php$ 加  /
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule>

Leave wordpress迁移/更换服务器后固定链接404错误 to:

Written by

Read more #wordpress posts


Best Posts From SmallBrother

We have not curated any of laosan's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From SmallBrother