Copied to clipboard

Flag this post as spam?

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


  • magger 5 posts 85 karma points
    Jun 23, 2019 @ 13:49
    magger
    0

    Preview broken in Umbraco v 7.10.4

    Hello everyone,

    I have some trouble with the preview function in an Umbraco installation.

    The preview mode broke after i updated the CMS about a year ago, and now the client is really missing the feature.

    When entering preview mode this is what happens:

    enter image description here

    Does anyone have any idea where i should start bug-fixing this? I can see that i have a folder in /Umbraco/preview.old - can it be that I would have to correct some links? If so, does anybody know where?

    Thank you so much in advance.

    Best regards, Magnus

  • Stephen 26 posts 148 karma points
    Jun 23, 2019 @ 23:42
    Stephen
    0

    Hi Magnus,

    Do you have a web.config rewrite rule that is removing trailing slashes from URLs? I've encountered this same issue, and that was the cause.

    From what I've been able to work out, Umbraco 7+ expects the URL of the preview page to be something like:

    http://localhost:1234/umbraco/preview/?id=1234#?id=1234
    

    Adding a standard rewrite rule to remove trailing slashes results in a URL like the one in your screenshot, with no slash between 'preview' and the query string. This causes several requests for scripts and stylesheets that the preview mode relies upon to return 404 errors.

    I managed to work around this by adding a condition to my rewrite rule that ignores Umbraco Back Office URLs.

    <rule name="Remove trailing slash" stopProcessing="true">
        <match url="(.*)/$" />
        <conditions>
            <add input="{REQUEST_URI}" pattern="^/umbraco.*$" negate="true" />
            <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>
    
  • magger 5 posts 85 karma points
    Jun 24, 2019 @ 13:16
    magger
    0

    Hi Stephen,

    Thank you for reaching out!

    I have the following rewrite rules in my web.config file:

    <rewrite>
            <rules>
                <rule name="Redirect HTTP to HTTPS" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
                </rule>
                <rule name="Redirect to non-www" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="www\.filuren\.dk$" />
                    </conditions>
                    <action type="Redirect" url="http://filuren.dk/{R:1}" redirectType="Permanent" />
                </rule>
                 <rule name="Remove 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>
                 <rule name="Remove trailing slash2" 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>
                 <rule name="Remove trailing slash3" 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>              
            </rules>
        </rewrite>
    

    Should i rewrite the rewrite rules? ;)

    I don't seem to have the REQUEST_URI input.. But i am not that familiar with rewrite rules.

    Thank you in advance.

  • Stephen 26 posts 148 karma points
    Jun 24, 2019 @ 20:53
    Stephen
    100

    Hi Magnus,

    That's correct. The line

    <add input="{REQUEST_URI}" pattern="^/umbraco.*$" negate="true" />
    

    is a condition that:

    1. Gets the Request URI. This is everything after the hostname i.e. "/umbraco/preview/?id=1234#?id=1234"
    2. Checks if this string starts with "/umbraco".
    3. If true, ignores the rewrite rule.

    You'll need to add this to your own "Remove trailing slash" rules to have them not be applied to the Umbraco Back Office.

  • magger 5 posts 85 karma points
    Jun 30, 2019 @ 13:37
    magger
    0

    hey Stephen

    Sorry for the slow reply!

    That worked - Thank you so much.

    Have a great day!

Please Sign in or register to post replies

Write your reply to:

Draft