0

I have a static website. I am trying to add a trailing slash to all URLs.

I have removed the .html extension on all URLs and did a 301 redirect from .html to non .html. See the code below

   location / {
        try_files $uri $uri/ =404;
        rewrite ^/cookies.html$ /cookies permanent;
        rewrite ^/event.html$ /event permanent;
        rewrite ^/faq.html$ /faq permanent;
        rewrite ^/index.html$ /index permanent;
        rewrite ^/terms-and-condition.html$ /terms-and-condition permanent;
        rewrite ^/([^\.]+)$ /$1.html break;

    }

How do I add trailing slashes to all the URLs so I can have /cookies/ instead of /cookies ?

Al John
  • 612
  • 5
  • 24
  • Does this answer your question? [nginx rewrite html file and add trailing slash](https://stackoverflow.com/questions/41618603/nginx-rewrite-html-file-and-add-trailing-slash) – rx2347 May 11 '23 at 17:27

0 Answers0