Nginx下WordPress后台链接地址缺少”wp-admin”

2015年2月13日12:48:34网站建设评论751

服务器由LAMP更换为LNMP后,性能确实好了很多,尤其是多连接并发时,再也没有出现内存不够的情况了。但是今天在登录Wordpress后台时发现了一个问题:点击后台的所有连接,网站均返回404,仔细查看发现,网站的URL里面都没有wp-admin了,全都变成类似:http://www.duoluodeyu.com/post-new.php的网址了。原因是我们进入网站后台控制面板时wp-admin后面没有“/”,如果有“/”就不会出现上面类似的问题。文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

WordPress官方也注意到了以上问题,给出了以下解决办法:文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

http://codex.wordpress.org/Nginx文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

你可以编辑你的wordpress站点的配置文件进行修改:vim /usr/local/nginx/conf/wordpress.conf(请根据站点具体配置文件修改)文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

location / {
index index.html index.php;
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;
}
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

保存后,重启Nginx即可。文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

/root/lnmp restart文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

文章推荐:Nginx环境配置WordPress伪静态规则文章源自堕落的鱼-https://www.duoluodeyu.com/1080.html

匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定