Copied to clipboard

Flag this post as spam?

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


  • Anders Brohus 194 posts 475 karma points
    May 10, 2019 @ 06:47
    Anders Brohus
    0

    Umbraco Cloud - Redirect

    Hi Our! :)

    Hope you guys can help me with some redirects which i'm not the best at.. :)

    I have an Cloud project with two envirements, live and dev :)

    https://anders-s-sensitive-beaver.s1.umbraco.io/

    https://dev-anders-s-sensitive-beaver.s1.umbraco.io/

    I want to redirect the live envirement to my actual domain, but keeping the dev envirement.

    <rule name="Redirects umbraco.io to actual domain" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^(.*)?.s1.umbraco.io$" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/umbraco" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/DependencyHandler.axd" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/App_Plugins" />
        <add input="{REQUEST_URI}" negate="true" pattern="localhost" />
      </conditions>
      <action type="Redirect" url="http://<your actual domain here>.com/{R:0}" 
              appendQueryString="true" redirectType="Permanent" />
    </rule>
    

    This one redirects everything.. So i tried reconfigure it to this,

    <rule name="Redirects umbraco.io to actual domain" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="anders-s-sensitive-beaver.s1.umbraco.io" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/umbraco" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/DependencyHandler.axd" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/App_Plugins" />
        <add input="{REQUEST_URI}" negate="true" pattern="localhost" />
      </conditions>
      <action type="Redirect" url="http://<your actual domain here>.com/{R:0}" 
              appendQueryString="true" redirectType="Permanent" />
    </rule>
    

    But it still wont work like i want to, how is i supposed to do?

  • Søren Kottal 713 posts 4571 karma points MVP 6x c-trib
    May 10, 2019 @ 07:19
    Søren Kottal
    100

    Hi Anders

    The pattern is a regex, so you need to make it not match your dev-environment.

    You could add your first one, to a config transform for your live environment. That is what I usually do, because then I can have the rule on my baseline project, and only need to change the redirect url.

    You could also add a ^ to your HTTP_HOST pattern. This means, that the host must start with the pattern..

    <rule name="Redirects umbraco.io to actual domain" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^anders-s-sensitive-beaver.s1.umbraco.io$" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/umbraco" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/DependencyHandler.axd" />
        <add input="{REQUEST_URI}" negate="true" pattern="^/App_Plugins" />
        <add input="{REQUEST_URI}" negate="true" pattern="localhost" />
      </conditions>
      <action type="Redirect" url="http://<your actual domain here>.com/{R:0}" 
              appendQueryString="true" redirectType="Permanent" />
    </rule>
    
  • Anders Brohus 194 posts 475 karma points
    May 10, 2019 @ 07:28
    Anders Brohus
    0

    Thanks alot Søren :)

  • Alan Mitchell 57 posts 281 karma points c-trib
    Jul 26, 2021 @ 09:15
    Alan Mitchell
    0

    Quick note to help others because it caught me out with a recent deployment. If your dev environment starts redirecting to live automatically check if you have a redirect like this.

    If so do not forget to update it to cope with the new DNS names for Umbraco Cloud projects

     <add input="{HTTP_HOST}" pattern="^dev-SITENAME.s1.umbraco.io$" />
    

    becomes:

     <add input="{HTTP_HOST}" pattern="^SITENAME.euwest01.umbraco.io$" />
    

    Alternately you could do it properly with transforms to only add the redirect rule on the live environment - instructions are here: https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Config-Transforms/

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies