Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Why is http://compassionpit.com/blog/ going through an infinite redirect loop? Here's my nginx conf file. The site is run by a nodejs server on port 8000 and Apache serves up the blog (wordpress) and the forum (phpBB). The forum is resolving just fine, at http://www.compassionpit.com/forum/ ...

This webpage has a redirect loop The webpage at http://www.compassionpit.com/blog/ has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

server {
    listen          80;
    server_name     www.compassionpit.org;
    rewrite         ^/(.*) http://www.compassionpit.com/$1  permanent;
}


server {
    listen       80;                # your server's public IP address
    server_name  www.compassionpit.com;
    index        index.php index.html;

    location ~ ^/$ {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location @blogphp {
        internal;
        root /opt/blog/;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
        fastcgi_index  index.php;
        fastcgi_pass   127.0.0.1:8080;
    }

    location ~ ^/(forum|blog)/($|.*\.php) {
        root /opt/;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_index  index.php;
        fastcgi_pass   127.0.0.1:8080;
    }

    location ~ ^/(forum|blog) {
        root /opt/;
        try_files $uri $uri/ @blogphp;
    }

    location ~ ^/(forum|blog)/ {
       root /opt/;
    }


    location @backend {
        internal;
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location ~ / {
        root /opt/chat/static/;
        try_files $uri $uri/ @backend;
    }

}
share|improve this question

3 Answers 3

up vote 2 down vote accepted

Is WordPress configured to use www or without www? Your server seems to be listening only for the www version and tries to redirect non-www requests to the www version.

Considering that you provided a link to the non-www version of the domain above, my guess is that WordPress is trying to hook on to http://compassionpit.com, but your server redirects those requests to http://www.compassionpit.com and WordPress redirects it back to http://compassionpit.com.

If that is indeed what's going on, either kill the www redirect on your server or tell WordPress (by setting your options directly through phpMyAdmin) to use the www version of the domain.

share|improve this answer
    
Excellent, that sounds exactly like what I should do! What setting in the SQL should I edit? I'm comfortable with going in directly to MySQL, I just have no idea what table to look at and what entry/field to adjust... :) –  Zachary Burt Aug 24 '11 at 20:09
1  
Take a look at siteurl and blog_url in the settings table (wp_options). The Codex is a good reference as well. –  EAMann Aug 24 '11 at 20:27
    
Very very helpful. Thank you so much. I had to change the 'home' option_value and the 'siteurl' option_value. –  Zachary Burt Aug 26 '11 at 0:28

Also check ownership/permissions. If WordPress can't do it's job, something like this will fail over and over again:

if (!-e $request_filename) { rewrite ^.+/?(/wp-.*) $1 last; rewrite ^.+/?(/.*\.php)$ $1 last; rewrite ^(.+)$ /index.php?q=$1 last; }

share|improve this answer

When this happened to me, I solved it by adding the following to theme's functions.php

remove_filter('template_redirect', 'redirect_canonical');
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.