Have an issue where we want to add trailing slashes to all URL's in a commerce site.
It's for SEO reasons. What is the best/correct way to do this?
I started with IIS rewrite rules but it seems to be hard to do it this way. It seems easy to break things and it seems to be hard to maintain.
I have to exclude so many path and it's seems easy to miss some path.
Some people in old posts suggest to use SegmentContext.PermanentRedirect but I'm not sure if this is the correct way.
It's anyway seems to be better choice then the IIS rules.
After the first try it don't seems to have any effect so I'm not sure.
Another options I have seen is UseTrailingSlash. But it's seems to only work on SEO url's and not on the hierarchical routing.
Also seen method SetupSeoUriPermanentRedirect but I'm not sure the effect of that or how to use it.
We use Commerce 11.2, CMS 10.10 and has hierarchial routing as below.
This has some good discussions: https://world.episerver.com/forum/developer-forum/Developer-to-developer/Thread-Container/2018/3/redirect-all-urls-so-they-end-with-/
It seems as the answer could be found in that article.
I used the last example with RoutedContent and got it to work.
I just had to add some more criteria in our solution that the RequestUrl not should contain a question mark.