Add slash to the base url

Prateek Dayal lists at
Wed Mar 31 17:34:51 MSD 2010


I am trying to add a trailing slash to every url and I have been able to
[almost] achieve that with this rule

if ($request_method ~* get){
  rewrite ^(.*[^/])$ $1/ permanent;

The if condition is to prevent redirection of POST requests to GET
requests. Urls such as http://localhost/anything are redirected to
http://localhost/anything/ but I am not able to redirect
http://localhost to http://localhost/

Am I missing something?

Prateek Dayal
Posted via

More information about the nginx mailing list