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

in wordpress •  7 years ago  (edited)
症状
  • 迁移/更换服务器后,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>
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!