Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stan 8 posts 72 karma points
    Aug 24, 2020 @ 19:32
    Stan
    0

    Routing /page.htm to /Page (Url alias with a dot/extension in them)

    Is there any way in Umbraco 8 to take a route with a .htm extension and route it to an umbraco page? For example, I simply want:

    /page.htm

    to route to my Umbraco site:

    /Page

    I have tried using Umbraco Url Alias, but that doesn't seem to work with file extensions.

    I have found a few Umbraco 7 solutions, but nothign that will work with 8.

  • Steve Morgan 1350 posts 4460 karma points c-trib
    Aug 25, 2020 @ 15:07
    Steve Morgan
    100

    Hi,

    I think this rewrite rule will work - you can add it in the web.config.

    <rules>
      <rule name="Rewrite .htm ext">
        <match ignoreCase="true" url="^(.*).htm"/>
        <conditions logicalGrouping="MatchAny">
          <add input="{URL}" pattern="(.*).htm"/>
        </conditions>
        <action type="Rewrite" url="{R:1}"/>
      </rule>
    

    More info here: https://our.umbraco.com/documentation/Reference/routing/iisrewriterules/

  • Stan 8 posts 72 karma points
    Aug 25, 2020 @ 16:23
    Stan
    0

    You are the man! Didn't think of the easy way... thank you so much!

  • Stan 8 posts 72 karma points
    Aug 25, 2020 @ 16:48
    Stan
    0

    Note: The above will break your Back Office, but I changed it slightly to knly catch room level .htm requests:

    <rewrite>
        <rules>
            <rule name="Rewrite .htm ext">
                <match ignoreCase="true" url="^(\w*).htm"/>
                <conditions logicalGrouping="MatchAny">
                    <add input="{URL}" pattern="(.*).htm"/>
                </conditions>
                <action type="Rewrite" url="{R:1}"/>
            </rule>
        </rules>
    </rewrite>
    
  • Steve Morgan 1350 posts 4460 karma points c-trib
    Aug 25, 2020 @ 18:41
    Steve Morgan
    0

    Or maybe, I think you need to add a negation.. something like

    <rules>
      <rule name="Rewrite .htm ext">
        <match ignoreCase="true" url="^(.*).htm"/>
        <conditions logicalGrouping="MatchAny">
          <add input="{URL}" pattern="(.*).htm"/>
           <add input="{REQUEST_URI}" url="^umbraco/.*" negate="true" />
        </conditions>
        <action type="Rewrite" url="{R:1}"/>
      </rule>
    
  • Stan 8 posts 72 karma points
    Aug 25, 2020 @ 18:49
    Stan
    0

    That's even better

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies