Removing trailing slashes example (Redirects) #98
-
|
The Craft Cloud redirect doc currently provides this example: I believe this adds a trailing slash to all URLs which typically Craft at the application level can do, what is the correct reverse logic to always trim trailing slashes? This would be great for redirection purposes where an old path like: /example/page/ Would be automatically redirected: /example/page And if an redirect rule from something like Retour existed that would be matched but only for non-trailing slash variant |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
|
@jamesmacwhite redirecting to a trimmed trailing slash is exactly the same, but without a trailing slash: Because of how Proably a good idea to include both examples in our docs, though. /cc @AugustMiller |
Beta Was this translation helpful? Give feedback.
@jamesmacwhite redirecting to a trimmed trailing slash is exactly the same, but without a trailing slash:
Because of how
URLPattern'spathnamematching works, thepathname: '/:noSlashes+'will match/all/the/segments/but/no/trailing/slash, so we just need to reference the match and include the trailing slash or not.Proably a good idea to include both examples in our docs, though. /cc @AugustMiller