V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
greyfreedom
V2EX  ›  WordPress

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

  •  
  •   greyfreedom · 2015-11-28 20:39:38 +08:00 · 3785 次点击
    这是一个创建于 3069 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    10 条回复    2015-11-29 15:23:41 +08:00
    xiaoz
        1
    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
        2
    Starduster  
       2015-11-28 20:48:42 +08:00
    查一下 nginx 的 rewrite 规则?
    greyfreedom
        3
    greyfreedom  
    OP
       2015-11-28 21:13:28 +08:00
    @Starduster 我是使用一个 apach rewrite 规则转换到 nginx rewrite 规则的网站转换的。我不太懂那个规则
    wql
        4
    wql  
       2015-11-28 21:34:18 +08:00 via Android
    @greyfreedom 千万不要直接转换那个规则!
    正确规则如下:(啥缓存都没有的话)
    location / {try_files $uri $uri/ /index.php;}
    xuhaoyangx
        5
    xuhaoyangx  
       2015-11-28 21:42:15 +08:00
    @greyfreedom 不要用自动转换
    给个地址 用 wsc 的可以参考下
    http://www.lovelucy.info/ngnix-config-support-wp-super-cache.html
    Starduster
        6
    Starduster  
       2015-11-28 21:52:23 +08:00
    @greyfreedom 这样一句 try_file 就行了,那些重写都删了吧

    location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
    }
    greyfreedom
        7
    greyfreedom  
    OP
       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
        8
    greyfreedom  
    OP
       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
        9
    greyfreedom  
    OP
       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
        10
    wql  
       2015-11-29 15:23:41 +08:00 via Android
    @greyfreedom 我差不多是明白了,你大概是把 WordPress 后台设置的 home 的地址设置成了 http://xxx/blog 了
    那么设置是有点麻烦。
    我给你的是默认根目录安装的配置,也祝贺你的网站已经恢复。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2575 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:59 · PVG 23:59 · LAX 08:59 · JFK 11:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.