Domain pointers, subfolders and URL rewriting

Discussion in 'Domain names / DNS' started by michiko, Mar 28, 2014.

  1. I have a question about the use of domain pointers. This is something which I would like to get set up early next week, but I'd like to check my requirements are possible before forging ahead.

    We have the following set up on our DiscountASP.NET account:

    www.MySite.com (This is our product's marketing site)
    www.MySite.com/app (This is our app where registered users can log in)​

    And this is the directory structure:

    [root]
    -- <files for marketing site>
    -- /app
    <files for registered users app>
    We have registered another domain which we'd like to point to the registered users app like this:


    I understand that I can set up a domain pointer, but I also noted the following:

    IMPORTANT NOTE ABOUT ROOT DOMAIN POINTERS:
    - The Root Domain Pointer addon has a one time setup fee of $15 per domain name.
    - This addon will point additional domain name(s) to the root of your primary hosted domain.
    - You can enable email aliases with Root Domain pointers.
    - We DO NOT point additional domains to subdirectories.

    So we can do this:

    but that only gets us half way there! I also read the following KB article which says that, having done the above, we can use the IIS URL rewrite module to redirect to a subfolder: https://support.discountasp.net/KB/a1131/how-to-host-multiple-domains-under-one-account.aspx. I'm not overly familiar with the URL rewrite module, so I have a couple of questions:

    1. I assume I need to modify the web.config for the marketing site (i.e. the root site), to make it redirect to the /app folder if it detected that the request came from www.MyOtherSite.com. Is that correct?

    2. What URL will show in the browser's address bar after this has happened? We need it to show either www.MyOtherSite.com or www.MyOtherSite.com/app. Either would be acceptable, but it must not show www.MySite.com or www.MySite.com/app.

    3. Are there any implications for using SSL?

    If it makes any difference, this is an ASP.NET MVC 4 application.
     
  2. martino

    martino DiscountASP.NET Staff

    Thank you for describing your issue clearly.

    1. Yes, that is correct.

    2. I'm not that great with URL rewrite but the easiest thing you can do with is edit the default documented on the root of the main site. Then use the instructions from our knowledge base article on http://support.discountasp.net/KB/a369/how-to-redirect-a-subdomain-to-a-subdirectory.aspx for the code.

    So this is what you need to put in your default document on the root of the site account.

    Code:
    <%
    If InStr( UCase(Request.ServerVariables("SERVER_NAME")),  UCase("www.MyOtherSite.com") ) > 0 Then
            Response.Redirect("/app")
    ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("MyOtherSite.com") ) > 0 Then
            Response.Redirect("/app")
    End If
    %>
    The end result will be "www.MyOtherSite.com/app" or "MyOtherSite.com/app" in the web browser. It won't show your original domain name for the site account in the URL browser.

    The default document is the first web page you see when you visit your site via: www.MySite.com It might be named "Default.aspx" , "Index.aspx" or what ever you use as the default document for your main site.

    3. The SSL Certificate can only work for one domain name. I'm not exactly sure what your question is but if you need instructions on how to enable an SSL Certificate for your site account please read our knowledge base article here: http://support.discountasp.net/KB/a138/activating-ssl-for-your-account.aspx

    The common name you choose will only be protected. It also depends on what type of SSL Certificate you install for the site account.
     
    mjp likes this.
  3. Hi Martino, thanks for your quick reply, much appreciated.

    I've read that it's not a good idea to use Response.Redirect in an MVC application, and the equivalent would be for the default controller to return a RedirectResult, which redirects to "/app". This should have the same effect as your sample code. I'll try this, and also the URL rewrite approach, and see which one works best.

    I've spoken to my colleague about the SSL certificate and it does sound like we'll need another certificate to cover www.MyOtherSite.com.

    Many thanks for your help!
     
  4. Returning to the SSL question...

    We already have a RapidSSL certificate with www.MySite.com as the common name. If we want to have both www.MySite.com and www.MyOtherSite.com secured, do we need to get a multi-domain certificate? Is this something that we can do via discountasp.net? Apologies if this is a basic question, but I don't often get involved with SSL certificates :)
     
  5. OK, so I've ordered the domain pointer and started to implement this, but have hit a problem already. Please could you advise?

    www.MyOtherSite.com is registered with a different registrar, so I've changed the A record with that registrar to www.MySite.com's IP address, as suggested here: https://support.discountasp.net/KB/a1131/how-to-host-multiple-domains-under-one-account.aspx

    (I haven't attempted to redirect to the "app" subfolder yet... that will come later once I get the first bit working!)

    The DNS change seems to have propogated and if I type www.MyOtherSite.com into my browser, it now redirects to www.MySite.com, BUT the address bar also changes to www.MySite.com! This is no good, I need it to say www.MyOtherSite.com.

    Could this be because I changed the A record, rather than changing the nameservers to DiscountASP.NET's nameservers?
     
  6. martino

    martino DiscountASP.NET Staff

    Yes, if you want to secure both of the domain names you will need to use a Multi-domain name SSL Certificate. We do support that in our hosting envirment. However, you can't order the Multi-Domain name SSL Certificate through us. You will need to go directly to a SSL provider that sells Multi-Domain name SSL Certificates and order it through them. This also means that you need to regenerate the CSR using our control panel for the main domain name of the site account. Provide that CSR to the SSL provider and they will issue the SSL Certificate to you. Once you received that SSL certificate. You can then copy and paste it into our control panel. Side note: You only need to generate the CSR with one of your common names you wish to use. You add the domain names for the SSL certificate through your SSL provider.

    Do you know if you have a redirect rule on the root of the site account to always redirect the requests as "www.MySite.com"? If so that might be the cause of this problem.

    Do you know for a fact if you're using A records or CNAME records to point : www.MyOtherSite.com to www.MySite.com ?

    It would be best to use A records because that will not change the URL in the web browser. The only cause for that would be if you have a redirect rule to redirect the requests to: www.MySite.com

    By default a domain pointer will always point to the root of the site account in our hosting environment and it doesn't change the URL in the web browser.
     
    mjp likes this.
  7. This is exactly what the problem was. :) The redirect is now working perfectly, many thanks for your help.
     
    RayH, mjp and martino like this.
  8. martino

    martino DiscountASP.NET Staff

    Very cool. Glad I was able to help out :)
     
    RayH and mjp like this.

Share This Page