0

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...

1
  • What for you want this? Commented Sep 24, 2014 at 19:40

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.