Setting up a beta subdomain

Discussion in 'Domain names / DNS' started by robertS, Aug 29, 2013.

  1. This is my first website so apologies in advance for any loose terminology etc.

    I have published my web app via FTP to mydomain.com and I want to now create a sub domain beta.mydomain.com where I can test new functionality before moving it across to the main site. Reading other posts, it sounds like once I have the subdomain mydomain.com/beta there are a few ways to map it to beta.mydomain.com.

    However, do I really need to create a Domain Pointer to get mydomain.com/beta to point to my subfolder under the FTP root directory which would have the beta site?

    If so, it almost feels more desirable to resister a new domain mydomain-beta.com and set up a new account with DASP (cost would also the same-ish).

    Does anyone have any thoughts on the most straightforward way to set up this beta site?
     
  2. Update:
    O.k so to have beta.mydomain.com I need to enable the 'unlimited subdomains' addon which I've now done. By default all subdomains are pointing to the root. I then put the below code (from elsewhere on this site) into a file named default.aspx and put it into the root directory.

    Code:
    <%
    If InStr( UCase(Request.ServerVariables("SERVER_NAME")),  UCase("beta.mydomain.com") ) > 0 Then
            Response.Redirect("/beta/")
    End If
    %>
    I don't have any other files called default or index there so I believe this will be treated as the default. It's not redirecting to the beta web app though and so I tried:
    Code:
    <%
        Response.Redirect("/beta/")
    %>
    to try and see if it was even reaching this default.aspx file or not but it's still not running the beta app.

    The files and folders in the beta folder are simply the published files and folders from a ASP.NET MVC 4 project, essentially the same format as what is in the root directory.

    Is there perhaps some obvious beginner mistake I'm making, such as the file format of the script? Any help would much appreciated!
     
  3. martino

    martino DiscountASP.NET Staff

    You have to put the code in the file that first loads on the root of your hosting account.

    So for example when you go to your site at mydomain.com the first page that loads in that directory (root) is the page where you need to input that code.

    Also, from the code you provided... take out the extra / after beta. so your code should look like this:

    Code:
    <%
    If InStr( UCase(Request.ServerVariables("SERVER_NAME")),  UCase("beta.mydomain.com") ) > 0 Then
            Response.Redirect("/beta")
    End If
    %>
    That way when someone types in beta.mydomain.com in the URL browser it will hit the default document in the root and since you have that rule in place it should redirect to the subdirectory /beta
     
    mjp likes this.
  4. O.k. So I think I still must be misunderstanding which directory this should live in. The web app is a simple modification of the ASP.NET MVC 4 template and I left the home default page as index.cshtml which lives in a Views folder. I've put the modified default.aspx file there in that folder but still doesn't get redirected to the beta site. Is this the correct folder?

    On a side note, I did manage to add a rule to the main site's web.config using the url rewrite below but I quite like the visibility of running a script i.e. separate file I can edit simply.

    Code:
    <rewrite>
          <rules>
            <rule name="beta.mydomain.com" stopProcessing="true">
              <match url=".*" />
              <conditions>
                <add input="{HTTP_HOST}" pattern="^www.beta.mydomain.com$" />
                <add input="{PATH_INFO}" pattern="^/beta/" negate="true" />
              </conditions>
              <action type="Rewrite" url="\beta\{R:0}" />
            </rule>
          </rules>
        </rewrite>
    Thanks
     
    mjp likes this.
  5. That is very true, but you can also "edit" this in the Web.config file that is part of the project. If what you want is to achieve redirection or more appropriately URL-rewriting, which is what you (and I) want, the reality is that IIS is the way to do so THROUGH the URL-rewrite module, or a custom extension to it. I don NOT recommend messing up with redirecting/URL-rewriting code in your Global.asax.

    Bear in mind however, that when using URL-rewriting via the standard URL-rewrite module, or any other programmatic feature that depends ultimately on this module, the virtual path to the application (Web Application) will include all the folders and sub-folders leading up to it from the root of the site.

    This will become apparent with trying to follow links or resolve relative paths in code: you will invariably see the your URLs starting with: http://subdomain.domain.com/subdomain/.

    If you want to completely simulate sub-domains as if they were hosted from the root of their own websites, more work is required.
     
  6. Thanks for you reply NinjackeR but I'm not really sure I understand when you say 'the reality is that IIS is the way to do so THROUGH the URL-rewrite module".
    I edited the web.config file only and didn't go into IIS, and when I go to beta.mydomain.com I can now redirect to my beta site at the desired site beta.mydomain.com (no forward slash anything). Given this is my first website, IIS 8 is confusing to me and I have been trying to avoid it, hence uploading via FTP.

    Why is IIS the way, given this is a first app?

    Thanks
     

Share This Page