Need help.
How to add slash to the end of every url except extensions?
I tied to use
rewrite ^(.*[^/])$ $1/ permanent; It is working but adding slash to the end of every URL including css, js, images...
Need help.
How to add slash to the end of every url except extensions?
I tied to use
rewrite ^(.*[^/])$ $1/ permanent; It is working but adding slash to the end of every URL including css, js, images...
I think this will work for you. Sadly we do not have a syntax for NOT in Nginx, so we have to make an empty match and then use / to match anything else.
location ~* ^.+\.(?:css|cur|js|jpg|jpeg|gif|htc|ico|png|html|xml)$ { # empty } location / { rewrite ^(.*[^/])$ $1/ permanent; } More info here.