More in this section

Forums / Developing with Sitefinity / Help with subdomain

Help with subdomain

12 posts, 0 answered
  1. jbull
    jbull avatar
    17 posts
    Registered:
    26 Jun 2012
    02 Apr 2008
    Link to this post
    has anyone successfully created subdomains in sitefinity.  I host my sites on shared servers with the Helm control panel and on non sitefinity sites i have s running fine for things like blogs.mydomain.com and formums.mydomain.com etc.  To do this i normally create the subdomain in Helm control panel and then create a virtual directory which points to where the physical directory that the blog or forum code is running out of.  In sitefininty the directories don't actually exist so that doesn't seem to work.  I've created Group pages for the subdomains to try and get that working but that didn't resolve it either.  Can anyone help?
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Apr 2008
    Link to this post
    Hi Jeff,

    We don't have such functionality out of the box, but we have already faced similar situation. We believe that this thread could help you achieve this scenario.

    Let us know if you need any further assistance.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. jbull
    jbull avatar
    17 posts
    Registered:
    26 Jun 2012
    07 Apr 2008
    Link to this post
    so, do i eliminate this line from the web.config  and add the new one mentioned in the post you references? add name="Cms" type="Telerik.Cms.Web.CmsHttpModule, Telerik.Cms"/>
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Apr 2008
    Link to this post
    Hello Juff,

    Yes, that's right, you have to remove the existing HttpModule in your web.config file and add the new one. The new HttpModule inherits the old one and expands its functionality.

    Sorry for this additional mail loop, I had to mention that earlier.

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. jbull
    jbull avatar
    17 posts
    Registered:
    26 Jun 2012
    09 Apr 2008
    Link to this post
    Ok, thanks for the confirmation, that is what i figured out. I implemented the solution as described in the post and added my subdomains which are pointed at group pages in sitefinity.  I went into our Helm control panel on our hosting and created the subdomains as well.  I'm just getting an error when i browse to the subdomains that the virtual directrory does not allow browsing.  These virtual directories worked fine before we implemented Sitefinity.

    Any ideas?  this is a real show stopper for us as we have lots of expensive literature and marketing pointed at those subdomains and now they are down.

  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    09 Apr 2008
    Link to this post
    Hi Jeff,

    All of your additional domains should point to only one virtual directory -  where the Sitefinity project is, not to other virtual directories.
    In the custom HttpModule that you have added, there is logic that checks the domain form which the request is coming, and then this module redirects to the right page group (one page group for one domain). In other words, the HttpModule should be able to catch all requests. If a request is directed to other than the project's virtual directory, the request will not be caught and not processed by this module.

    By the way, it is not recommended to test custom solutions directly on the production server.

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. jbull
    jbull avatar
    17 posts
    Registered:
    26 Jun 2012
    10 Apr 2008
    Link to this post
    I'm still not having any luck getting this working. The issue may be that in the Helm control panel on our hosting It does not appear that I can point the virtual directory for the subdomains to the root "\"   any other thoughts?
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    14 Apr 2008
    Link to this post
    Hi Jeff,

    We don't have other suggestions, because the solutions requires all requests to be handled by the HttpModule. Perhaps you should contact your hosting/domain provider. There must be a way to point your sub-domains to the root directory.

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. jbull
    jbull avatar
    17 posts
    Registered:
    26 Jun 2012
    16 Apr 2008
    Link to this post
    Ok, I got the subdomains working by having my host point all subdomains at the root so that the http module could handle them.  However, i am having a strange issue with the way that the http handler works.  I would like to use the subdomain to direct the guest to a specific area of the site, however once there I prefer that they be able to use the site navigation to get to other pages of the broader site if that makes sense.  For example if the user goes to the subdomain blogs.mywebsite.com  i want them to land on the blogs page which is a page group called "blogs" in the site  from that page they can still see the "products" and "support" menus of the site, clicking on those should take them to mywebsitesite.com/products  however it's sending them to blogs.mywebsite.com/products which gives me a 404 error.   Any ideas how to handle this?


  10. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    17 Apr 2008
    Link to this post
    Hello Jeff,

    The provided solution in this thread actually changes the SiteMap depending on the requested domain, so it displays only the pages under the mapped domain root page.

    As we understand you now, you want to view links to all domains pages in the SiteMap, right? In order to achieve this, you should change or remove the implementation in the DomainSiteMapProvider, which handles the above behavior.
    Or basically, you could implement your custom Http module which just redirects to a specific page depending on the requested domain.

    If you send us a complete description of the scenario you want to achieve, we could give you more advices and code solutions.

    Kind regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. jbull
    jbull avatar
    17 posts
    Registered:
    26 Jun 2012
    20 Apr 2008
    Link to this post
    This is the functionality that I am after, is basically to have the subdomain redirect user to page group in the site, but still allow them to get to other pages successfully.

    example: blogs.mydomain.com --> mydomain.com/blogs  or forums.mydomain.com --> mdomain.com/forums

    and once there, user can still access the rest of the site normally.

    Thanks,
    Jeff
  12. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    21 Apr 2008
    Link to this post
    Hello Jeff,

    Ok, then you should forget about the solution in this forum: http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-bbbahh.aspx.

    Most probably, you need a simpler workaround. For example, you could create a custom http module:
    using System; 
    using System.Collections.Generic; 
    using System.Web; 
    using Telerik.Cms.Web; 
     
    /// <summary> 
    /// Summary description for CustomHttpModule 
    /// </summary> 
    public class CustomHttpModule : IHttpModule 
        static CustomHttpModule() 
        { 
            defaultDomain = "mydomain.com"
            domains = new Dictionary<stringstring>(); 
            domains.Add("blogs.mydomain.com""blogs"); 
            domains.Add("forums.mydomain.com""forums"); 
        } 
        #region IHttpModule Members 
     
        public void Dispose() 
        { 
        } 
     
        public void Init(HttpApplication context) 
        { 
            context.BeginRequest += new EventHandler(context_BeginRequest); 
        } 
     
        void context_BeginRequest(object sender, EventArgs e) 
        { 
            HttpContext context = HttpContext.Current; 
            string currentDomain = context.Request.Url.Host; 
            string domainRoot = null
            if (!currentDomain.Equals(defaultDomain, StringComparison.OrdinalIgnoreCase)  
                && domains.TryGetValue(currentDomain, out domainRoot)) 
            { 
                string appPath = context.Request.ApplicationPath; 
                if (!appPath.EndsWith("/")) 
                    appPath += "/"
                context.Response.Redirect( 
                    String.Concat(context.Request.Url.Scheme, "://", defaultDomain, appPath, domainRoot, UrlHelper.PageExtension)); 
            } 
        } 
        #endregion 
     
        private static Dictionary<String, String> domains; 
        private static string defaultDomain; 
     
     

    You should add you http module before ours in the web.config:
      <system.web> 
        ... 
        <httpModules> 
          <add name="DomainRedirect" type="CustomHttpModule"/> 
          <add name="Cms" type="Telerik.Cms.Web.CmsHttpModule, Telerik.Cms"/> 
          ... 
     


    Hope this is helpful.

    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
12 posts, 0 answered