Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My server os is debian squeeze. I have these lines to redirect non-www to www in htaccess file of my website:

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

but it cause this error in firefox:

  The page isn't redirecting properly

  Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

  This problem can sometimes be caused by disabling or refusing to accept

when I comment those lines in htaccess mysite appears but in non-www format. I'm sure it works well before on the Ubuntu . but I don't know why it doesn't work now. would you help me?

share|improve this question

It may be that because you are using a 301 redirect, you are seeing a cached result. If you created the wrong redirect and tested it and then fixed it, you will still get the old, cached result in a browser like Firefox. Do your testing with curl --include

If you still get the same problem with curl, the problem is quite likely in the bit that you replaced with If those two strings aren't exactly the same, you will get a redirect loop.

It may also be worthwhile using 302 redirects until you are sure they are correct and only then switching to 301s.

share|improve this answer

Your Answer


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.