We've rebuilt our Website and our extensions will be .html
. Currently, they are .htm
. When a user visits our site from a bookmarked page for example that's .htm
, I want it to redirect to the .html
version.
I have looked through stackoverflow to see if there is already a Q&A on this. Most are Apache - .htaccess related. I'm using IIS. The closest answer I could find on stackoverflow is this one: IIS url rewrite rewriting all .asp to .html
I tried following the advice in that post, but it's not working. The webpage tells me This webpage has a redirect loop.
and Error code: ERR_TOO_MANY_REDIRECTS
I'm in the URL Rewrite module in IIS. I create a new "blank rule" for inbound rules. Here are the settings I'm using as advised by that stackoverflow post: (BTW, I would have posted this in that thread, but it's over 3 years old, so I wasn't sure if that was advised)
Requested URL: Matches the Pattern
Using: Regular Expressions
Pattern: (.*).htm(.*)
Ignore Case is checked.
Conditions: Local Grouping: Match All
I Added a condition...
Condition Method: {REQUEST_METHOD}
Check if input string: Matches the Pattern
Pattern: ^GET$
Ignore Case is checked
Action type: Redirect
Redirect URL: {R:1}.html{R:2}
Append Query String is checked
Redirect type: Permanent (301)
I'm doing a 301 because I want the search engines to know our URL extensions have changed. Our URLs are exactly the same. The only difference is they're going to be .html
instead of .htm
. So... something/something.htm
is something/something.html
.