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

http://xxx.xxx.xxx.xxx/123

I get redirected to

http://_/123

but when I try the url

http://xxx.xxx.xxx.xxx/123/

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:

http://wiki.nginx.org/HttpCoreModule#server_name_in_redirect

share|improve this answer

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

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.