Subdomain Help

Discussion in 'General troubleshooting' started by soulie, Jan 13, 2010.

  1. Hi,

    I am a new user to Winhost, I have set up my basic site but would now like to add more applications.

    My current situation:

    xxx.com => Website in "~Root" folder


    I would like to setup the following:

    xxx.com => Website in "~Root\MainWebsite\" folder
    test.xxx.com => Website in "~Root\TestWebsite\" folder
    blog.xxx.com => Blog app in "~Root\Blog\" folder

    I am having lots of difficulty with this, can someone please point out how I go about doing this? I don't even know how to set up xxx.com so that it looks to a non-root folder.

    Regards,

    - S


    *EDIT*

    Just to clarify as clear as possible I don't want my root application to be in the root directory.
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    Try using the IIS 7 URL Rewrite module to help you create the rule to achieve what you are trying to do. The URL Rewrite module makes url rewriting and redirecting easy but uses a lot of regular expressions just like CGI does, and if you are not used to regular expressions it can be pretty daunting and frustrating, so I also recommend doing a search on the Internet for regular expressions and read up on it. It can make things a lot less frustrating.

    Anyways, to get started on using the URL Rewrite module that comes with IIS 7 try using these guidelines to help you along. A word of advice, test this out by starting with something easy. At least for now. Try not to make the rules too complicated until you start getting use to it.

    1. Log into the server using IIS 7 Manager.
    2. Once you are logged in go to module labeled “URL Rewrite”. Click on ‘Add Rules…’, and choose ‘Blank rule’ from the Add rule(s) window
    3. Type a name for the rule.
    4. Make sure you choose ‘Matches the pattern’ in the Requested URL: drop down box and ‘Regular Expression’ in the Using: drop down box.
    In the Pattern text box type (.*)
    5. Click on the button ‘Add Conditions’ then under the drop down box labeled ‘Logical Grouping:’ choose ‘Match Any’ and click on the ‘Add’ button.
    6. Type {HTTP_HOST} for Condition input.
    7. Type ^sub1.mydomain\.com$ in the ‘Pattern:’ text box. Note the carrot sign ‘^’, the forward slash ‘\’, and the dollar sign ‘$’, these are regular expression symbols that you will need to add. Type the pattern just as I lay out.
    8. When the conditions are defined, you will be back in the Edit Rule window; choose ‘Rewrite’ in the ‘Action Type:’ drop down box.
    9. In the ‘Rewrite URL:’ text box type \sub1\{R:1}
    10. Put a check mark next to ‘Append query string’. Click on the Apply.

    Your rule is now setup.

    Bear in mind that \sub1\ is the folder where you uploaded your website into.
     
  3. Ray: Does this simple process work for WCF messages that use a subdomain and have to be redirected to a folder?

    thx

    --mike
     
  4. Ray

    Ray

    Yes it should. But WCF is kind of strict with the binding address so you may want to be careful with that.
     
  5. BIG problem is that the user sees the urls in folder format, not as a subdomain, so this is a real cludge. Is there a more elegant way, as godaddy provides automatically?
     
  6. Ray

    Ray

    You mean you don't want the subfolder to show?

    If it redirects to (as an example)..

    subdomain.domain.com/subfolder

    You only want it to show subdomain.domain.com

    If this is the case then you will need to also setup a URL Rewrite Rule. Not just a redirect rule.
     
  7. And how do you do that? That's what I'm trying to do. I want to setup wiki.xinbi.com, but I want it to point to \wik\WebApplication

    Consequently, if you go to wiki.xinbi.com it doesn't look like you're being re-directed to wiki.xinbi.com\wik\WebApplication, but rather that wiki.xinbi.com is rooted at the wiki application page.
     
  8. Ray

    Ray

    Last edited by a moderator: Oct 14, 2015
  9. So does anyone have this working. I've been screwing with this for five hours and still no luck. No less than six samples and it's just not doing it. I even changed everything around to wildcards, return an error code instead of rewrite or redirect, and I'm still stuck.

    I second a post in another thread - pointing a sub domain to a sub dir should be a 'click done' thing.
     
  10. Agreed. What's the point of having a subdomain if it just points to the root of the main domain? +1 vote for 'add/point/click/done'. I know that we're paying a cheap price for domain hosting (and I expect to do more of the technical stuff myself because of it), but subdomains that aren't really subdomains is kinda silly, IMHO.
     
  11. Ray

    Ray

    I wish it could be this easy by with a Windows platform configured as a shared hosting environment, there's nothing on the server we can set to do this. What it looks like you need to do is setup a URL Rewrite.

    IIS 7 has a URL rewrite module. First read this kb article to get IIS 7 Manager to connect to our server.

    http://support.Winhost.com/KB/a628/using-the-microsoft-iis-70-manager.aspx

    Once you are connected you will see a module called URL Rewrite. It can be pretty complex depending on what you want to do. I suggest you first read through this link to get to know the URL Rewrite module.

    http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

    Here is a thread from the forum that helps give an example on how to setup a Rewrite rule with the module.

    http://forum.Winhost.com/showthread.php?t=3910
     
    Last edited by a moderator: Oct 14, 2015
  12. I read all of that before I posted. Still, I had no luck. I don't even care about rewrite - I was just doing a simple redirect. I've done this before using a default page script, but it messes up link backs.

    If anyone has this working, could you post the file? Also, just so I'm clear - I am not complaining :)
     
  13. Ray

    Ray

    If you want a subdomain to hide its true path,

    As an example,

    you have sub.mydomain.com and it points to sub.mydomain.com/folder1 but you want it to show sub.mydomain.com then you cannot only use a redirect script but a rewrite script or also known as a rewrite rule. For this the URL Rewrite module is the best way to go about this.
     
  14. i want to add *.domainname.com in subdomain manager but it shows error - 'Subdomain contains invalid characters'. what should i do?
     
  15. Ray

    Ray

    You cannot have a wild card subdomain name. You need to define each subdomain name individually.
     
  16. I have yet to get the URL Rewrite to work correctly for what I (and I think mikev) want to do. Maybe we need a step-by-step guide like in the above post to get it to work.
     
  17. Ray

    Ray

    How detailed do you want to get?

    Did you try going through the steps I outline in one of the threads from this post?

    Its really hard to do a step-by-step on a forum.
     
  18. I thought the steps outlined above were quite good, actually. They didn't work for what I wanted, however.
     
  19. problem identifying if URL Rewrite is being picked up



    Ray, thank you for your time spent on explaining the URL Rewrite, it was top notch. I am having a problem though and I dont know how to check it:
    - I want to rewrite http://staging1.mydomain.co.uk/anything.html to use http://www.mydomain.co.uk/staging1/anything.html
    - I have configured my remote IIS7
    - I have followed your Rewrite rule to the letter (missed out the parenthesis initially on the (.*) part)
    - it saves nicely with no errors
    - yet when i go to http://staging1.mydomain.co.uk/anything.html I get a server error and see its still looking at wwwroot\anything.html

    Do i need to configure subdomains in my account? Or will the URL rewrite rule override these?

    Am i missing anything else?

    NOTE: I am hosting the domain elsewhere, should I set up any particular DNS records? I have *.mydomain.co.uk working fine, and as you can see from the server error above, it knows where it is looking for the file.

    Help REALLLY appreciated, as I intend to set up 2 staging sites (staging1 and staging2) for this purpose.

    Kind Regards JIm
     
  20. Ray

    Ray

    Is "www.mydomain.co.uk/staging1/anything.html" an actual path. Meaning under the root you have a folder staging1 with the web page anything.html. Because if you do maybe something like this is more suited with a redirect rather then a Rewrite.
    Rarely do I get someone asking to rewire a subdomain name to the domain name of the account. Typically it is the other way around.
     
  21. Hi Ray, amazingly quick response!!

    Yes it is an actual path, although I'm actually using test.html to see if this is working (in case you are looking at my account which is account ID 0005374)

    The main reason I suspect a simple redirect wont work is that this website has about 200 pages in it, and all the links in the host are relative to the root. Remembering I want to have 2 staging sites on this account which are full copies of the original site (for testing purposes). So if I have a page:
    www.mydomain.co.uk/login.asp i want to have staging sites:
    staging1.mydomain.co.uk/login.asp (which will be a file located here: www.mydomain.co.uk/staging1/login.asp) and also
    staging2.mydomain.co.uk/login.asp (which will be a file located here: www.mydomain.co.uk/staging2/login.asp)

    The links in the 2 pages /staging1/login.asp and /staging2/login.asp would both have href's something like href="/join.asp" and I therefore want them linking to staging1.mydomain.co.uk/join.asp (i.e. ..co.uk/staging1/join.asp.

    i.e. I'm trying not to have every link link to the original www folder.

    Does that makes sense?

    Thanks again
    Jim
     
  22. Incidentally I think is a great example of why people might want to use rewrites rather than redirects (for subdomains -> subfodlers)... if my assumption that URLs written relative to the absolute site root would jump out of the subfolder using a redirect
     

Share This Page