Copied to clipboard

Flag this post as spam?

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


  • Bezmundo 48 posts 139 karma points
    Dec 28, 2017 @ 15:27
    Bezmundo
    0

    Adding Trailing Slash Rewrite breaks Umbraco backend

    Hi, Having an issue with adding a redirect to add a trailing slash to URL's.

    When the rule below is applied it causes the backend of Umbraco not to load as it can no longer find Angular or required files.

    <rule name="Add trailing slash" stopProcessing="true">
    <match url="(.*[^/])$" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    
    </conditions>
    <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
    </rule>
    

    Running Umbraco 7.5.4

    Thank you

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Dec 28, 2017 @ 16:33
    Nik
    101

    Hi Bezmundo,

    Add this to your Conditions list:

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

    It should exclude any umbraco elements from your re-write rule including surface controllers and similar.

    Thanks,

    Nik

  • Patrick van Kemenade 101 posts 339 karma points
    Jan 14, 2020 @ 13:16
    Patrick van Kemenade
    2
            <rule name="Add trailing slash" stopProcessing="true">
          <match url="(.*[^/])$" />
          <conditions>
            <add input="{URL}" negate="true" pattern="^/umbraco.*$" />
            <add input="{URL}" negate="true" pattern="^/app_plugins.*$" />
            <add input="{URL}" negate="true" pattern="^/install.*$" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_FILENAME}" pattern="(.*?)\.[a-zA-Z]{1,4}$" negate="true" />
          </conditions>
          <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
        </rule>
    

    This is what I ended up with, besides /umbraco there might be other plugins or code that can't handle the rewrite. If anybody has any suggestions or additions to this I would like to hear it (I'm not a IIS guru).

    Please also note, if this rule is not the last one in your list the stopProcessing must be false.

Please Sign in or register to post replies

Write your reply to:

Draft