views:

223

answers:

2

I'm googling a lot and found several workarounds, but you have to deinfe every single directory.

On Apache: example.com/hi -> example.com/hi/ On nginx: example.com/hi -> Firefox can't establish a connection to the server at example.com:8888

where 8888 is what Apache is listening on (nginx's :80 -> localhost:8888)

Any ideas how to fix this and have it just forward normally like folder?

A: 

The following should do the trick, but it needs more thought/work, because only a single location block will get used at a time:

location ~ ^(.*[^/])$ {
  if (-d $document_root/$1) {
    rewrite ^(.*)$ $1/ permanent;
  }
}

(not tested)

blueyed
+1  A: 

You can set "server_name_in_redirect off" on your server section

server{ listen 80 default; server_name localhost; server_name_in_redirect off;

... ... }

That will do the trick ;-)

HTH.

Esparta Palma
This fixed a redirect problem for me. +1!
Adam Backstrom