Copied to clipboard

Flag this post as spam?

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


  • Tim 15 posts 75 karma points
    Jan 22, 2016 @ 18:41
    Tim
    0

    Umbraco in child virtual directory

    Our client has an IIS configuration wherein they have a main site and a child site in a virtual directory beneath the main site. The Umbraco instance needs to be installed in the child site.

    Our current problem is that certain Umbraco pages do not work properly in the backoffice in this configuration. For instance, preview doesn't work...unless we change certain paths in /umbraco/preview/index.html to use .. instead of /umbraco. We are now finding that there are more pages that suffer from this problem (/umbraco/settings/Views/EditView.aspx, for instance).

    Is there some setting we can change that will allow Umbraco to resolve paths properly without having to modify every Umbraco ASPX page (which would be a non-starter, as that would be required to be done every time we update)? This is a show-stopping problem for us.

  • Jason Elkin 38 posts 351 karma points MVP 2x c-trib
    Jan 22, 2016 @ 22:23
    Jason Elkin
    0

    This may have been fixed as of 7.3.2. Take a look at http://issues.umbraco.org/issue/U4-1117

    I have two projects on this machine, one 7.3 which has absolute URLs in those files you mentioned and 7.3.5 which uses relative URLs.

    I'm not sure about the rest of the application though. In my experience virtual directories are trouble and are to be avoided wherever possible. If you're able to convince your client of the virtues of sub-domains you'll save yourself (and your client) a lot of headaches like this one.

  • Tim 15 posts 75 karma points
    Jan 25, 2016 @ 19:29
    Tim
    0

    Thanks for the advice, Jason. Can anyone else out there confirm if 7.3.2 fixes this issue?

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jan 25, 2016 @ 09:02
    Ismail Mayat
    0

    Tim,

    We also had client with this setup we had some fun and games with packages failing in some instances we have had to mess with package source leblender being one of them.

    Regards

    Ismail

  • Tim 15 posts 75 karma points
    Feb 02, 2016 @ 21:45
    Tim
    0

    I upgraded to 7.3.6 and this issue has now been fixed.

  • Prashant 8 posts 78 karma points
    Aug 22, 2016 @ 15:58
    Prashant
    0

    Hi Guys,

    Is there any way to fix the following for 7.3.1?

    I have configured an umbraco 7.3.1 website in IIS successfully and is working fine. Now, i have a requirement to add this Umbraco 7.3.1 Website to be inside a virtual directory converted to application in another parent website (Umbraco 7.3.1). But there is an issue while running that 7.3.1 site as subsite. When i tried to access this site as for example like, Umbraco7.3.1site/Umbraco7.3.1Subsite. We are getting the follwing error.

    enter image description here

    Please provide your solutions for it, i have wasted almost a week over it.

    My route for the 7.3.1 site is: "D:\delete me\UmbNewInstances\Parent" Route for the 7.3.1 subsite is: "D:\delete me\UmbNewInstances\Child"

    Let me know if someone wants any input from my side.

  • Jonathan Maurer 5 posts 72 karma points
    Sep 18, 2017 @ 14:04
    Jonathan Maurer
    0

    I'm having the same issue, trying to load an Umbraco site inside a virtual directory of another Umbraco site, did you ever manage to get it right?

  • Jonathan Maurer 5 posts 72 karma points
    Sep 18, 2017 @ 14:16
  • Jonathan Maurer 5 posts 72 karma points
    Oct 11, 2017 @ 12:14
    Jonathan Maurer
    1

    Found a Solution that works kinda well in certain instances:

    Introduction

    There are several instances where you may find you want to, or need to install multiple Umbraco sites on a single domain and for some reason cannot accomplish this with subdomains which would be the easiest solution. As virtual directories are not an option since Umbraco does not support this, we have to come up with a different solution. To this end one method that works is URL rewrites.

    Goal

    The final outcome is to show how to run two ( or more ) Umbraco sites and children of a single parent site.

    Example layout:

    http://my.umbraco.site/

    http://my.umbraco.site/UmbracoSite2

    http://my.umbraco.site/UmbracoSite3

    Prerequisites

    To run this setup, you must have the following:

    1. IIS 7 or above with ASP.NET role service enabled.

    2. URL Rewrite Module installed version 2.0 or above

    3. Application Request Routing version 1.0 or version 2.0 installed

    Implementation

    First Configure all three sites as such:

    my.umbraco.site

    Site2.my.umbraco.site – Turn Off gzip Compression

    Site3.my.umbraco.site – Turn Off gzip Compression

    Enabling Reverse Proxy functionality

    Reverse Proxy functionality is disabled by default, so you must begin by enabling it.

    1. Open IIS Manager

    2. Select a server node in the tree view on the left hand side and then click on the "Application Request Routing" feature:

    3. Check the "Enable Proxy" check box. Leave the default values for all the other settings on this page:

    4. Go To my.umbraco.site -> URL Rewrite -> (link on the left “View Server Variables”)

    5. Add 2 variables:

      • HTTPACCEPTENCODING -HTTPXORIGINALACCEPTENCODING

    Web.config my.umbraco.site

    First we need to tell out Base Umbraco install that we have two folders where it must not intercept and block traffic to by updating umbracoReservedPaths

    <add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/UmbracoSite3/,~/UmbracoSite2/" />
    

    Now comes the fun part, setting up the rewrite and reverse proxy rules, this is where the magic happens. The URL rewrites will be places in the top of the

    First we are going to add rules to “Proxy” the requests from the Umbraco site to one of the sub sites.

    <rule name="Reverse Proxy to Site2" stopProcessing="true">
    <match url="^UmbracoSite2(.*)" />
    
    <action type="Rewrite" url="http://Site2.my.umbraco.site/{R:1}" />
    <serverVariables>
    
    <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
    <set name="HTTP_ACCEPT_ENCODING" value="" />
    </serverVariables>
    </rule>
    

    This on it’s own will give you a basic workable site where all the links and css are broken, but your basic HTML is served. From here you can create a site that functions well enough if you develop it correctly, if however you want to take an existing site and do this, then you require a few further steps.

    There are three major sections we need to look at, namely CSS, HTML, and Redirects which are all fixed via outbound rules. The next step is to define these section.

    <preCondition name="isHtml">
    
    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
    
    </preCondition>
    
    <preCondition name="IsCSS">
    
    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/css" />
    </preCondition>
    
    <preCondition name="IsRedirection">
    
    <add input="{RESPONSE_STATUS}" pattern="3\d\d" />
    
    </preCondition>
    

    Now that our sections are defined we can create Rules for each of them.

    HTML

    This rewrites the HTML searching for tags matched in the filter tags section and matches anything between quote tags that starts with “/” and prepends it with the corresponding matched pattern from the URL being rewritten.

    <rule name="Add application prefix" preCondition="isHtml">
    <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" />
    <conditions>
    
    <add input="{URL}" pattern="^/(UmbracoSite2|UmbracoSite3).*" />
    </conditions>
    <action type="Rewrite" value="/{C:1}/{R:1}" />
    
    </rule>
    

    Redirects

    The below rule intercepts response redirects ( HTTP Response Code 3?? Eg. 301 ) and prepends the matched URL to the response URL.

    <rule name="Response Status Update" preCondition="IsRedirection" stopProcessing="true">
    <match serverVariable="RESPONSE_Location" pattern="^/(.*)" />
    <conditions>
    
    <add input="{URL}" pattern="^/(UmbracoSite2|UmbracoSite3)/.*" />
    </conditions>
    <action type="Rewrite" value="/{C:1}/{R:1}" />
    
    </rule>
    

    CSS

    The CSS in this case references Media in both the media library and content section of the site, this should be updated to match your configuration of where images are referred to from your css.

    <rule name="Rewrite image URLs in CSS response /content/" preCondition="IsCSS">
    <match pattern="/Content/" />
    <conditions>
    
    <add input="{URL}" pattern="^/(UmbracoSite2|UmbracoSite3)/.*" />
    </conditions>
    <action type="Rewrite" value="/{C:1}/Content/" />
    
    </rule>
    
    <rule name="Rewrite image URLs in CSS response /media/" preCondition="IsCSS">
    
    <match pattern="/media/" />
    
    <conditions>
    
    <add input="{URL}" pattern="^/(UmbracoSite2|UmbracoSite3)/.*" />
    </conditions>
    <action type="Rewrite" value="/{C:1}/media/" />
    
    </rule>
    

    Once you are done your Rewrite section in system.webServer should look something like this:

    <rewrite>
    
    <rules>
    
    <rule name="Reverse Proxy to Site2" stopProcessing="true">
    
    <match url="^UmbracoSite2(.*)" />
    
    <action type="Rewrite" url="http://Site2.my.umbraco.site/{R:1}" />
    <serverVariables>
    
    <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
    <set name="HTTP_ACCEPT_ENCODING" value="" />
    </serverVariables>
    
    </rule>
    
    <rule name="Reverse Proxy to Site3" stopProcessing="true">
    
    <match url="^UmbracoSite3(.*)" />
    
    <action type="Rewrite" url="http://Site3.my.umbraco.site/{R:1}" />
    <serverVariables>
    
    <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
    <set name="HTTP_ACCEPT_ENCODING" value="" />
    </serverVariables>
    </rule>
    
    </rules>
    
    <outboundRules>
    
    <rule name="Rewrite image URLs in CSS response /content/" preCondition="IsCSS">
    
    <match pattern="/Content/" />
    <conditions>
    <add input="{URL}" pattern="^/(UmbracoSite2|UmbracoSite3)/.*" />
    </conditions>
    <action type="Rewrite" value="/{C:1}/Content/" />
    </rule>
    <rule name="Rewrite image URLs in CSS response /media/" preCondition="IsCSS">
    
    <match pattern="/media/" />
    <conditions>
    <add input="{URL}" pattern="^/(UmbracoSite2|UmbracoSite3)/.*" />
    </conditions>
    <action type="Rewrite" value="/{C:1}/media/" />
    </rule>
    <rule name="Add application prefix" preCondition="isHtml">
    
    <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" />
    <conditions>
    <add input="{URL}" pattern="^/(UmbracoSite2|UmbracoSite3).*" />
    
    </conditions>
    <action type="Rewrite" value="/{C:1}/{R:1}" />
    
    </rule>
    <rule name="Response Status Update" preCondition="IsRedirection" stopProcessing="true">
    
    <match serverVariable="RESPONSE_Location" pattern="^/(.*)" />
    <conditions>
    <add input="{URL}" pattern="^/(UmbracoSite2|UmbracoSite3)/.*" />
    </conditions>
    <action type="Rewrite" value="/{C:1}/{R:1}" />
    </rule>
    
    <preConditions>
    <preCondition name="isHtml">
    
    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
    </preCondition>
    <preCondition name="IsCSS">
    <add input="{RESPONSE_CONTENT_TYPE}" pattern="text/css" />
    </preCondition>
    <preCondition name="IsRedirection">
    <add input="{RESPONSE_STATUS}" pattern="3\d\d" />
    </preCondition>
    </preConditions>
    </outboundRules>
    
    </rewrite>
    

    Rewrite action Key:

    {C:1} - Condition Match Group 1

    {R:1} - Rule Match Group 1

    Javascript

    Javascript can be handled in a similar fashion by adding a preCondition and similar rules

    <preCondition name="IsJS">
    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/javascript" />
    
    </preCondition>
    

    OR

    in the javascript itself as such

    var BasePath = "UmbracoSite2/"; if (~$(location).attr('href').indexOf("Site2.my.umbraco.site")) {

    BasePath = "";

    }

    Notes

    While this covers the majority of the sites there will always be minor changes that will be required with your individual site.

  • Arnaud VATEL 6 posts 78 karma points
    Apr 07, 2021 @ 15:51
    Arnaud VATEL
    0

    Hi Jonathan,

    I know this thread is a bit old but I am in the same situation on Umbraco8 and tried your solution. It's working great except for one thing : on UmbracoSite2 or 3, images with a query string in the url don't appear anymore (for example https://my.umbraco.site/Site2/media/4cyhe4f4/1664.png?height=30). But It works if I remove the parameters after ? I suspect that the rewriting prevents ImageProcessor to do his job.

    Does anybody have any idea why and how I could fix that ?

    Thanks in advance, Arnaud

Please Sign in or register to post replies

Write your reply to:

Draft