Reaching out to community after many hours of head scratching.
I have a site that contains a rewrite rule to remove trailing slash from all URLs. This site also has 301 URL Tracker package installed.
Removal of the trailing slash works OK unless the URL contains both accented character and trailing slash, if it does, the resulting redirect is an incorrect URL.
Problem is that you are doing multiple redirects causing the issue as first redirect is encoding and then 2nd one further encode it. You can check it here.
http://www.redirect-checker.org/index.php
I have updated below rule and have added UrlDecode. However, you can try by adding old page to new page rule on top of RemoveTrailingSlashRule or vice versa.
yep you are right, based on the chrome network tab trace, there is definitely double encoding happening.
Unfortunately, your suggestion didn't help to decode the URL. The final url was still double encoded.
During investigation, I have tried to replace your suggested UrlDecode with UrlEncode which surprisingly resulted in correctly generated URL with the trailing slash removed... but, all slashes encoded to %2F :/
Anyway, after another day of puzzling, I have decided to remove the trailing slash removal rewrite rule from web.config and replaced it with a bit of code that hooks into the Umbraco page request to manually remove the trailing slash from URL and all works as expected.
Default behaviour of umbraco is adding slash. So, why do you want to remove slash. We have generally used below Canonical code to add slash for all the links in Umbraco to ensure same Canonical for slash and non-slash links.
Redirect Url encoding with trailing slash
Reaching out to community after many hours of head scratching.
I have a site that contains a rewrite rule to remove trailing slash from all URLs. This site also has 301 URL Tracker package installed.
Removal of the trailing slash works OK unless the URL contains both accented character and trailing slash, if it does, the resulting redirect is an incorrect URL.
Example:
requested url:
http://site.local/old-page/terre-dhermès-edt/
rewritten url:
http://site.local/new-page/terre-dhermès-edt
Looking at the network tab in chrome I can also see 2 encoded request URLs.
1st:
http://site.local/terre-dherm%C3%A8s-edt/
- 3012nd:
http://site.local/terre-dherm%C3%83%C2%A8s-edt
- 404Also, if I remove the rewrite rule from web.config the Url is encoded correctly and the redirect works fine - but obviously trailing slash stays.
Anyone has experienced anything similar here?
My trailing slash removal redirect:
Thanks
Jakub
Hi Jakub,
Problem is that you are doing multiple redirects causing the issue as first redirect is encoding and then 2nd one further encode it. You can check it here. http://www.redirect-checker.org/index.php
I have updated below rule and have added UrlDecode. However, you can try by adding old page to new page rule on top of RemoveTrailingSlashRule or vice versa.
Let me know how it goes?
Thanks for the reply,
yep you are right, based on the chrome network tab trace, there is definitely double encoding happening.
Unfortunately, your suggestion didn't help to decode the URL. The final url was still double encoded.
During investigation, I have tried to replace your suggested
UrlDecode
withUrlEncode
which surprisingly resulted in correctly generated URL with the trailing slash removed... but, all slashes encoded to%2F
:/Anyway, after another day of puzzling, I have decided to remove the trailing slash removal rewrite rule from web.config and replaced it with a bit of code that hooks into the Umbraco page request to manually remove the trailing slash from URL and all works as expected.
Thanks for the help.
Jakub
Hi Jakub,
Default behaviour of umbraco is adding slash. So, why do you want to remove slash. We have generally used below Canonical code to add slash for all the links in Umbraco to ensure same Canonical for slash and non-slash links.
Hi,
Thanks for the suggestion.
I have inherited this site and think that the removal of the trailing slash was just a requirement.
Jakub
is working on a reply...