dourong8495 2013-11-14 14:09
浏览 74

Wordpress nginx重定向循环

So, yesterday I had a question how to install the wordpress in the "/root" directory. I wasn't very successful in that one and I forgo'ed on that one.

So, right now the wordpress is located under "/var/www/wordpress" (so it's under separate folder) folder (I use Ubuntu 12.04 LTS, if it matters).

And my problem is that right after I had configured everything (everything was working like a charm there) I was redirected to the admin panel page. Everything was working fine up until the moment when I tried to visit the blog.

The URL address for my blog is: "blog.mysite.com". That is why I use NGINX, because I have two different applications (and environments) on one server and I need to distinguish between them.

So, the fact is: blog.mysite.com/wp-admin (/wp-login.php) is working totally OK, but when I visit the front page: blog.mysite.com, it keeps telling me that there is an endless redirect loop (301 redirect according to nginx access log file).

In admin panel I have both "WordPress Address (URL)" and "Site address (URL)" set to: "http://blog.mysite.com". Modifying either of them to something else, like: "http://blog.mysite.com/wordpress" is not helping at all!

".htaccess" file is empty, but I'm using default permalinks, so should not be a problem (However, I'm not sure).

Both nginx and apache2 root directives are pointing to "/var/www/wordpress". Static files (css,js) are working, if it matters.

How can I fix this problem ? Any help is much appreciated!

Thank you in advance!

  • 写回答

5条回答 默认 最新

  • douhe1864 2013-11-14 14:33
    关注

    I had a lot of problems when switching from Apache to Nginx in the past, all solved when I purged Apache, which somehow was interfering with Nginx and caused problems to every server. Here is my wordpress configuration for Nginx, according to both Nginx and Wordpress guides for each other:

    server {
        listen 80;
        server_name blog.mysite.com;
    
        root /var/www/wordpress;
        index index.php;
    
        charset utf-8;
    
        location / {
          try_files $uri $uri/ /index.php?$args;
        }
    
        location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
            access_log off; log_not_found off; expires max;
        }
    
        location ~ \.php$ {
            try_files $uri /index.php;
    
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # CHANGE THE LINE ABOVE IF NEEDED
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    

    I didn't even have to change anything in the admin panel when switching servers, it just worked fine.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度