Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

Check your php. I had similar problem when I had redirect($_SERVER['SERVER_NAME']) in my login.php. I replaced it with redirect($_SERVER['HTTP_HOST']) 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

Try this in your config:

server_name_in_redirect off;

See the relevant docs here:


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.