skip down to add a comment

Fixing the trailing slash in Nginx

The solution as usual is super simple. The problem I was having was that when you didn’t put a trailing slash on a url, it would not handle it and throw a 404. I saw lots of fixes with complex re-write rules, but it turns out that a simple fix for me was to add this to my .conf file:

# http://wiki.nginx.org/NginxHttpCoreModule#server_name_in_redirect
server_name_in_redirect off;

So your *.conf would look like this

server {
  listen  80;
  server_name  localhost;
  ...
  server_name_in_redirect off;
  ...
}

Oh dear, there have been no responses yet to this post.

Go ahead, have your say ..

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">


back to the top