nginx - 404 when missing backslash

Fairly new to nginx, does anyone know why this happens?

http://xxx.xxx.xxx.xxx/folder/ - opens fine

http://xxx.xxx.xxx.xxx/folder - redirects to: http://www.li46-80.com/folder/

2 Replies

Usually, web servers will redirect from http://blah/directoryname to http://hostname/directoryname/ for various reasons. Odds are good that it thinks your hostname is li46-80, so it's really redirecting you to http://li46-80/folder/ and your browser is sticking the www and com on it because it can't resolve li46-80.

It's probably getting that from the system hostname, which is probably set from the reverse DNS for your IP. In Apache, ensuring ServerName is set correctly is the way to go; nginx probably has a similar setting. I bet that will fix it :-)

Either you have an error in your rewrite rules, or you may've fallen victim to this peculiarity of Nginx.

Incidentally, it's a normal slash.

EDIT: Aargh, too slow :) And in hindsight, hoopycat is probably right.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct