wordpress 博客更换服务器后登陆后台提示“此网页包含重定向循环”

2015-11-28 20:39:38 +08:00
 greyfreedom

前几天我给自己的 wordpress 博客更换了服务器,并且从原来的 lamp 换成了 lnmp 。
换完之后去后台登陆,点击登陆后提示我“此网页包含重定向循环”。清楚了 cookie 也不管用。看网上的解决方法更改了 capabilities.php 和 template-loader.php 部分内容也不行。
请问有没有哪位遇到过这个问题?

3789 次点击
所在节点    WordPress
10 条回复
xiaoz
2015-11-28 20:47:16 +08:00
我倒是前段时间从 AMH 更换到 LNMP 1.2 也遇到坑爹的问题。大概从以下几个方面排查:
1..user.ini 文件,可参考: http://www.xiaoz.me/archives/6237
2.PHP 版本原因,看一下你之前 LAMP 的 PHP 版本是多少,然后把 LNMP 版本也切换为一致试试。
3.插件或者主题原因,将 wp-content/plugins 目录先改名排除下插件,然后将当前使用的主题改名( wp-content/thems )排查主题
4.你得网站是不是强制使用了 https ,先关闭后再试一下。
5.还是不行,可以加下 QQ : 337003006 一起讨论一下。
Starduster
2015-11-28 20:48:42 +08:00
查一下 nginx 的 rewrite 规则?
greyfreedom
2015-11-28 21:13:28 +08:00
@Starduster 我是使用一个 apach rewrite 规则转换到 nginx rewrite 规则的网站转换的。我不太懂那个规则
wql
2015-11-28 21:34:18 +08:00
@greyfreedom 千万不要直接转换那个规则!
正确规则如下:(啥缓存都没有的话)
location / {try_files $uri $uri/ /index.php;}
xuhaoyangx
2015-11-28 21:42:15 +08:00
@greyfreedom 不要用自动转换
给个地址 用 wsc 的可以参考下
http://www.lovelucy.info/ngnix-config-support-wp-super-cache.html
Starduster
2015-11-28 21:52:23 +08:00
@greyfreedom 这样一句 try_file 就行了,那些重写都删了吧

location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
greyfreedom
2015-11-29 14:21:54 +08:00
@Starduster 换成你这句还是不行。我把以前的转货过来的规则删掉了以后可以登录后台了,但是现在文章点开都是 404.。。。
我现在的配置文件是这样的:
location / {
try_files $uri $uri/ /index.php;

}

error_page 404 /404.html;


error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}

以前直接转换规则的时候的 location /里面是这样的
location / {
try_files $uri $uri/ /index.php;
#ignored: "-" thing used or unknown variable in regex/rew
if (!-f $request_filename){
set $rule_1 1$rule_1;
}
if (!-d $request_filename){
set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
rewrite /. /blog/index.php last;
}

}

现在情况是这样的:
如果是第一种配置,可以访问后台页面,且没有问题。但是所有文章、分类,下一页等连接都是 404.
如果是第二种情况,所有文章、分类、下一页都没问题。但是后台登陆页面可以访问,点击登陆后重定向过多,无法进入控制台。
greyfreedom
2015-11-29 14:22:04 +08:00
@wql 换成你这句还是不行。我把以前的转货过来的规则删掉了以后可以登录后台了,但是现在文章点开都是 404.。。。
我现在的配置文件是这样的:
location / {
try_files $uri $uri/ /index.php;

}

error_page 404 /404.html;


error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}

以前直接转换规则的时候的 location /里面是这样的
location / {
try_files $uri $uri/ /index.php;
#ignored: "-" thing used or unknown variable in regex/rew
if (!-f $request_filename){
set $rule_1 1$rule_1;
}
if (!-d $request_filename){
set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
rewrite /. /blog/index.php last;
}

}

现在情况是这样的:
如果是第一种配置,可以访问后台页面,且没有问题。但是所有文章、分类,下一页等连接都是 404.
如果是第二种情况,所有文章、分类、下一页都没问题。但是后台登陆页面可以访问,点击登陆后重定向过多,无法进入控制台。
greyfreedom
2015-11-29 14:36:51 +08:00
@wql @Starduster 同志们,我解决了。。。。虽然我也不知道什么原因弄好的。。。
我把配置文件贴一下,以便以后侥幸能够帮助有同样问题的人。
谢谢各位。谢谢。
location / {
if (!-f $request_filename){
set $rule_1 1$rule_1;
}
if (!-d $request_filename){
set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
rewrite /. /blog/index.php last;
}
try_files $uri $uri/ /index.php;

}

error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
wql
2015-11-29 15:23:41 +08:00
@greyfreedom 我差不多是明白了,你大概是把 WordPress 后台设置的 home 的地址设置成了 http://xxx/blog 了
那么设置是有点麻烦。
我给你的是默认根目录安装的配置,也祝贺你的网站已经恢复。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/239679

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX