Copied to clipboard

Flag this post as spam?

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


  • Barry Corrigan 32 posts 145 karma points
    Jan 29, 2018 @ 09:30
    Barry Corrigan
    0

    My 301 redirect rule breaks the Umbraco control panel

    Hi there,

    I have the following 301 redirect rule which redirects all clean URL directory's to a .aspx extension

    for example

    (Old URL) - domain.com/about-us (Redirect URL) - domain.com/about-us.aspx

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

    While this works. It breaks the Umbraco control panel when I login

    This is what the control panel looks like

    enter image description here

    This is the errors I'm seeing

    enter image description here

    Has anyone got any ideas on how to get around this so the Umbraco control panel doesnt break while still keeping the redirects in place?

    Thanks Barry

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Jan 29, 2018 @ 09:55
    Steve Morgan
    0

    Hi,

    I think Niels' whitelist approach will help you here

    https://24days.in/umbraco-cms/2014/redirect-rules/

    HTH

    Steve

  • Barry Corrigan 32 posts 145 karma points
    Jan 29, 2018 @ 10:58
    Barry Corrigan
    0

    Thanks for that, yes that did work, but the redirect rule I had in place stopped working.

  • Barry Corrigan 32 posts 145 karma points
    Jan 30, 2018 @ 15:24
    Barry Corrigan
    0

    I tried the following, but it's not working for me, has anyone any ideas on how to sort this

    <rewrite>
    <rules>
    <rule name="Add ASPX" stopProcessing="true">
      <match url="(.*[^/])$" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_URI}" pattern="(.*[^/]).aspx$" negate="true" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="{R:1}.aspx" />
    </rule>
    <rule name="WhiteList" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
        <add input="{URL}" pattern="^.*/(base|webshop|umbraco|umbraco_client|client|install|api|bundles)/" ignoreCase="true" />
        <add input="{HTTP_HOST}" pattern=".*localhost.*" ignoreCase="true" />
    </conditions>
    <action type="None" />
      </rule>
    </rules>
    </rewrite>
    
  • Steve Morgan 1348 posts 4457 karma points c-trib
    Jan 30, 2018 @ 16:11
    Steve Morgan
    0

    Hi,

    Try

    <rule name="Append aspx" stopProcessing="true">
          <match url="^(.*)" ignoreCase="true"/>
          <conditions logicalGrouping="MatchAll">
            <!-- if mydomain.com is requested without a page -->
            <add input="{URL}" pattern="(.*).aspx" negate="true"/>
            <add input="{URL}" pattern="^$" negate="true"/>
            <add input="{URL}" pattern="^\/$" negate="true"/>
            <!-- umbraco backoffice and api bits and bats -->
            <add input="{URL}" pattern="^.*/(base|webshop|umbraco|umbraco_client|client|install|api|bundles)/" negate="true"/>
            <add input="{URL}" pattern="^.*/umbraco" negate="true"/>
          </conditions>
          <action type="Redirect" url="{R:1}.aspx"/>
        </rule>
    

    There's some specific rules not to redirect the default homepage (e.g. mydomain.com/.aspx)

    HTH

    Steve

  • Barry Corrigan 32 posts 145 karma points
    Jan 31, 2018 @ 11:47
    Barry Corrigan
    0

    Unfortunately @Steve that didn't work. I 301 redirects are working, but the Umbaco CMS is still broke and now it doesn't display any images from the Media control panel within Umbraco.

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Jan 31, 2018 @ 11:51
    Steve Morgan
    0

    Hi,

    Have you cleared your cache and done a hard reload (in Chrome with dev tools press and hold the refresh button).

    Browsers cache 301 redirects so if you've changed the rules and fixed them you might not know.

    Steve

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Jan 31, 2018 @ 12:00
    Steve Morgan
    0

    Spotted some issues with files and app plugins.

    Clear you cache etc and try this one.

    <rule name="Append aspx" stopProcessing="true">
              <match url="^(.*)" ignoreCase="true"/>
              <conditions logicalGrouping="MatchAll">
                <!-- if mydomain.com is requested without a page -->
                <add input="{URL}" pattern="(.*).aspx" negate="true"/>
                <add input="{URL}" pattern="^$" negate="true"/>
                <add input="{URL}" pattern="^\/$" negate="true"/>
                <!-- umbraco backoffice and api bits and bats -->
                <add input="{URL}" pattern="^.*/(base|webshop|umbraco|umbraco_client|client|install|api|bundles|app_plugins)/" negate="true"/>
                <add input="{URL}" pattern="^.*/umbraco" negate="true"/>
                <!-- files -->
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
              </conditions>
              <action type="Redirect" url="{R:1}.aspx"/>
            </rule>
    

    I've just tested it on a test install and I can access Umbraco, upload an image, display it on the front end. No errors on the homepage nor on the fav icon now.

  • Barry Corrigan 32 posts 145 karma points
    Jan 31, 2018 @ 12:26
    Barry Corrigan
    0

    What seems to be causing the issue is the following files, .aspx is being added to these files

    http://localhost/dependencyhandler.axd.aspx?s=L3VtYnJhY http://localhost/webresource.axd.aspx?d=LCyOdROYwNZqHgTdlgn http://localhost/scriptresource.axd.aspx?d=KHa0P8LBeKyX0Lhv http://localhost/scriptresource.axd.aspx?d=thqZfu9UvGgIdk1N

    Im not sure how to ignore a .axd file

  • Barry Corrigan 32 posts 145 karma points
    Jan 31, 2018 @ 12:42
    Barry Corrigan
    100

    I found by adding this it resolved the .axd issues

    <add input="{URL}" pattern="\.axd$" negate="true" />
    

    So the full rewrite rule is

    <rule name="Append aspx" stopProcessing="true">
        <match url="^(.*)" ignoreCase="true"/>
        <conditions logicalGrouping="MatchAll">
          <!-- if mydomain.com is requested without a page -->
          <add input="{URL}" pattern="(.*).aspx" negate="true"/>
          <add input="{URL}" pattern="^$" negate="true"/>
          <add input="{URL}" pattern="^\/$" negate="true"/>
          <!-- umbraco backoffice and api bits and bats -->
          <add input="{URL}" pattern="^.*/(base|webshop|umbraco|umbraco_client|client|install|api|bundles|app_plugins)/" negate="true"/>
          <add input="{URL}" pattern="^.*/umbraco" negate="true"/>
          <add input="{URL}" pattern="\.axd$" negate="true" />
          <!-- files -->
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        </conditions>
        <action type="Redirect" url="{R:1}.aspx"/>
      </rule>
    

    Thanks all for the help on this topic.

  • Barry Corrigan 32 posts 145 karma points
    Mar 14, 2018 @ 15:27
    Barry Corrigan
    0

    Hi there,

    The above works fine except for pages inside a folder

    i.e

    http://localhost/folder1/page1/

    If we have a trailing slash on this page it outputs the following:

    http://localhost/folder1/page1/.aspx

    Is there anyway to get around this? I tried the following but had no joy

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

    Anyone have any ideas on how to get around this?

    Thanks

  • Steve Morgan 1348 posts 4457 karma points c-trib
    Mar 14, 2018 @ 19:54
    Steve Morgan
    0
     <add input="{URL}" pattern="(.*)\/$" negate="true" />
    

    That work?

  • Barry Corrigan 32 posts 145 karma points
    Oct 24, 2018 @ 08:22
    Barry Corrigan
    1

    Hi Steve,

    Just realised I never replied to this post, but this is all working now and thanks for the help.

  • Barry Corrigan 32 posts 145 karma points
    Dec 04, 2018 @ 13:54
    Barry Corrigan
    0

    If I have a url with the following

    https://domain.com/parent-page/child-page.aspx

    If I strip out child-page.aspx I am left with /parent-page/ which leaves me with a trailing slash.

    How would I go about changing that so /parent-page/ redirects to /parent-page.aspx

    If I strip out the trailing slash on /parent-page/ it redirects fine. I would just like it to do it automatically if a user lands on a parent page with a trailing slash.

    I have tried the following but to no avail

    <add input="{URL}" pattern="(/*)\/$" negate="true" />
    
Please Sign in or register to post replies

Write your reply to:

Draft