Super User is a question and answer site for computer enthusiasts and power users. 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

I had just set up nginx on my server. I have PHP and everything working okay. Except when I try the URL

I get redirected to


but when I try the url

It works just as I want it to. How can I get nginx to treat the slashless url decently?

share|improve this question

Try this in your config:

server_name_in_redirect off;

See the relevant docs here:

share|improve this answer

Check your php. I had similar problem when I had


in my login.php. I replaced it with


and now everything is fine. $_SERVER['SERVER_NAME'] is the first domain in server_name directive in nginx and $_SERVER['HTTP_HOST'] is domain in request.

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.