I need to redirect all of the legacy .htm
urls for my website to extensionless urls, so:
http://www.website.com/page.htm --> http://www.website.com/page
I created the following rule in config/UrlRewriting.config, which fixed the above issue, but created an issue where all of the backoffice paths are returning 404:
<add name="HtmToExtensionless"
redirect="Domain"
ignoreCase="true"
rewriteUrlParameter="IncludeQueryStringForRewrite"
virtualUrl="http://www.website.com/(.*)(\.htm)"
redirectMode="Permanent"
destinationUrl="http://www.website.com/$1" />
So requests like these are returning 404:
http://www.website.com/umbraco/views/components/application/umb-navigationl?umb__rnd=7.4.2.1536555776
I'm pretty sure my problem is with my regex, but I'm not sure. Anyone care to advise?
Turns out I was being a dufus. Umbraco actually requests resources that have .html
extensions, and my regex was grabbing those and stripping the .htm
from them. Just had to check for the beginning and end of the string, and now we're golden:
<add name="HtmToExtensionless"
redirect="Domain"
ignoreCase="true"
rewriteUrlParameter="IncludeQueryStringForRewrite"
virtualUrl="^http://www.website.com/(.*)(\.htm)$"
redirectMode="Permanent"
destinationUrl="http://www.website.com/$1" />