Copied to clipboard

Flag this post as spam?

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

  • Rhys Baillie 2 posts 72 karma points
    Jul 12, 2017 @ 20:24
    Rhys Baillie

    Remove .html from Url using web.config produces errors

    Hi All, I've got a rewrite rule in web.config which is rewriting the URL to remove .html from all requests which is great, works like a charm.

    However it produces an error when looking in the CMS at any page which contains a Macro, where the Macro is unable to find the "GetMacroResultAsHtmlForEditor".

    I'm not convinces at publishing a page which produces errors for obvious reasons (it's a live site). I'm convinces that the rewrite rule is doing something to the Backend which is not great! The error is:

    Request error: The URL returned a 404 (not found): /umbraco/backoffice/UmbracoApi/Macro/GetMacroResultAsHtmlForEditor with data: {"macroAlias":"ImageSlider","pageId":"1258","macroParams":{}} Contact your administrator for information.

    and the rewrite rule is:

        <rule name="Hide .html ext">
          <match ignoreCase="true" url="^(.*)"/>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
            <add input="{REQUEST_FILENAME}.html" matchType="IsFile"/>
          <action type="Rewrite" url="{R:0}.html"/>
        <rule name="Redirecting .html ext" stopProcessing="true">
          <match url="^(.*).html"/>
          <conditions logicalGrouping="MatchAny">
            <add input="{URL}" pattern="(.*).html"/>
          <action type="Redirect" url="{R:1}"/>

    can anyone advise / help with this please? Umbraco version 7.4.3 assembly: 1.0.5948.18141 and using EUKHosts Plesk Hosting

    Many thanks


  • Marc Goodson 856 posts 5578 karma points MVP 3x c-trib
    Jul 13, 2017 @ 12:48
    Marc Goodson

    I'm not sure this is the answer, but one thing I noticed in your regex, is that the . before the html isn't escaped...

    and . in regex parlance means match anything and so maybe your:


    isn't matching everything before the .html

    but just being greedy and matching everything with html in

    can't see how it's necessarily related to the issue you are seeing but thought maybe


    might be closer to what you were trying to achieve, so apologies if it's a digression to the main question but thought I'd mention it anyway, not that I can ever remember what regex syntax should properly be!

  • Rhys Baillie 2 posts 72 karma points
    Jul 13, 2017 @ 21:58
    Rhys Baillie

    Hi marc goodson, thanks for that, it did correct the GetHtml.. error so big thanks for that! However, something else that I've noticed is that when adding an element to the grid, something that requires a setting input (such as a macro) the slide-in config page is blank. I suspect this rewrite is doing more harm than good and I should look for an alternative. Many thanks though, getting there!

  • Marc Goodson 856 posts 5578 karma points MVP 3x c-trib
    Jul 14, 2017 @ 08:07
    Marc Goodson

    Hi Rhys

    ahh, it's just to rewrite an old version of your site on the front end now you've moved to Umbraco and you want to make sure old links to the .html versions still work / redirect correctly.

    In which case you may have some joy by excluding the rewriting from applying to any request within the Umbraco folder - so it doesn't clash with the innerworkings, that will use .html files as views for some of the backoffice bits:

    eg add to your conditions:

      <add input="{URL}" pattern="/Umbraco/*" negate="true" />

    see if that helps.



Please Sign in or register to post replies

Write your reply to: