Copied to clipboard

Flag this post as spam?

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


  • Jeffrey Weinstein 67 posts 313 karma points
    Jun 13, 2017 @ 15:19
    Jeffrey Weinstein
    0

    Umraco angular2

    I recently built Umbraco Site, which is using angular form on the homepage and this angular form navigates between steps, let's say /step1 /step2 and /step3 . Now if user is on /step2 and refreshes the page he will get 404 because Umbraco have no idea angular is taking care of that. Can you please help me make Umbraco return same page (homepage in this case) on several different urls? Than angular will start and pickup the URL.

  • Phil Atkinson 51 posts 244 karma points
    Jun 14, 2017 @ 07:34
    Phil Atkinson
    1

    I've never used it but couldn't the urlRewriter in Umbraco work for you? Configure "/step2" to point to "/" (home in this case) ?

  • Jeffrey Weinstein 67 posts 313 karma points
    Jun 16, 2017 @ 04:31
    Jeffrey Weinstein
    0

    yeah, thanks for suggesting that, it works like a charm.

    <rewrite>
      <rewriteMaps>
        <rewriteMap name="StaticRewrites">
          <add key="/step1" value="/" />
          <add key="/step2" value="/" />
          <add key="/step3" value="/" />
          <add key="/step4" value="/" />
          <add key="/summary" value="/" />
          <add key="/thankyou" value="/" />
        </rewriteMap>
      </rewriteMaps>
      <rules>
        <rule name="Rewrite Rule">
          <match url=".*" />
          <conditions>
            <add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
          </conditions>
          <action type="Rewrite" url="{C:1}" />
        </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>
      </rules>
    </rewrite>
    

    Also I found this quite useful - redirect to HTTPS, if release configuration (you should put it to Web.Release.config) for automatic transformation.

    <system.webServer>
    <rewrite >
      <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true" xdt:Transform="Insert">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
    

Please Sign in or register to post replies

Write your reply to:

Draft