Quantcast
Channel: Red Row Studio » WordPress
Viewing all articles
Browse latest Browse all 10

How to fix an infinite 301 redirect loop in WordPress

$
0
0

I just ran into this problem today; thought I should post the solution in case anybody else finds themselves in the same boat.

I moved a WordPress blog from one server to another which was running lighttpd with a blanket 301 redirect to from www to non-www URLs. When I fired up a browser to test it, I got the dreaded “this website is responding in a way that will never resolve” message. A quick look at the lighttpd logs confirmed that I was bouncing from www.example.com to example.com then back to www.example.com.

I expected the first redirect but not the second, and checking in my lighttpd conf showed no rule that could possibly be triggering it. Thinking maybe I had left a redirection plugin running, I logged on the blog (by temporarily disabling the redirect rules) and checked, but couldn’t find anything.

Turns out that WordPress itself is capable of generating 301 redirects according to the “Blog URL” field in the General settings page. If the URL is set to http://www.example.com and a request comes in for http://example.com/some/page, then WordPress will automatically respond with a 301 redirect to http://www.example.com/some/page (which in my case, would get caught by my lighttpd rule and bounced back to the original request URL, and so on).

Moral of the story: make sure that your WordPress URL settings and any manual redirection you are carrying out are in agreement as to what the ‘correct’ URL should be!


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images