Subdomains point to main site?

Discussion in 'General' started by fooboo, Feb 26, 2010.

  1. fooboo

    fooboo New Member

    Using ISP config 3.0.1.6 (I just upgraded from 3.0.1.4 to see if that would resolve this problem...but it didn't)

    I may be misunderstanding something here but I've been trying to create a subdomain that points to it's own folder rather than the main site's homepage.

    It seems whatever I do when I create a subdomain it doesn't have it's own folder that I can then install a site to, it defaults to pointing at the tlds homepage and I can't see a field in the subdomain setup page that I could use to steer the subdomain to it's own folder.

    My tld is registered with namecheap. If I don't add a new subdomain record there it wont be found as I don't have a wildcard subdomain catchall set up.

    If I set up a subdomain with namecheap the address correctly resolves to my server.
    Once a request for <mysubdomain>.<mytld>.com is sent to my server I expected the host headers to steer it to the correct folder but I don't currently see a way of creating that setting.

    The only way I can cause ISPConfig to give a subdomain it's own unique folder is if I set it up as a new tld using the tld plus subdomain in the domain field. But even though it has it's own folder when I put the address in a browser I still get my homepage from my tld like it's not pointing to that new folder.

    Can anyone help?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Make sure that you created every subdomain as DNS A-Record at your domain registrar and that the IP of this dns A-Record is identiacl to the IP of the website that you created for this subdomain.

    The purpose of the subdomain function is to point subdomains to the same site then this subdomain belongs to. If you want to have a separate directory, you have to create the subdomain as separate website (domain).
     
  3. fooboo

    fooboo New Member

    Yes I've done this.

    I've done this also but the new site (using the websites option not the subdomain one) has a directory created for it as I would expect and I can see in the vhosts file that it points to this new separate directory which has the default index.html file added to it but instead of seeing this "Welcome" page when I navigate to the domain which should be using this separate folder I get my homepage from my original tld site which is in a different folder so something somewhere is telling my server when a request comes in using the subdomain's url go to the tlds folder.
     
  4. fooboo

    fooboo New Member

    I've even been clearing the cache of my browser just in case that was pulling up the homepage from cache.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Then you have to wait about 24 - 48 hours.

    and you are sure that you selected the IP address and not * in the site settings. It must be the IP that you created in the A-Record, otherwise apache is not able to find the correct website.
     
    niemand-glaumy likes this.
  6. fooboo

    fooboo New Member

    Ah! I put the IP address in at the registrar but on the ISPConfig page the drop down list only has the * as an option. There are no IP addresses and no way of entering one.
    I thought the host header would sort out the routing once it got to my box?
    I only have one static IP but that doesn't show up in the drop down list.


    The vhost file for this tld lists *.<tld> as an alias then <mysub>.<tld> below that as another alias.
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Then you missed to add it in the server settings (see system module).
     
  8. fooboo

    fooboo New Member

    I'm guessing that's one of the options when you are logged in as admin?
    I've lost my admin password (doh! :p) so I'll have to figure out how to recover that first, thanks for your help.
     
  9. fooboo

    fooboo New Member

    Ok I found out how to do that, I added the IP, it shows in the list so I've added it to the new domain too.
    Now I just have to wait for the registrar changes I made (I was messing around trying to get things to work another way) to go through and hopefully I'm sorted.
    Thanks again.
     
  10. fooboo

    fooboo New Member

    I've just set up a new subdomain with my registrar and set up a new website for that domain in ISPconfig and the subdomain already resolves to my server but again it gets there and goes straight to the homepage of my tld.
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Check if the vhost file exists and if it contains the correct IP and domain name. Check especially for typos.

    The reason for this problem is always the same, apache will redirect to the first site of an Ip as long as there is no better match for it. So if you get the main site, your subdomain vhost has either atypo in the IP or the servername or the dns record is incorrect.
     
  12. fooboo

    fooboo New Member

    Hmm I'm stumped. I've gone through everything and it all seems to be spelled properly and has the right IP. ISPConfig automatically generated the vhost files and directories so everything matches perfectly.

    I've checked out the A record and it's all fine and since it does find my server it's probably set up fine.

    It's just that last bit of navigation from the header. I removed the following line from the vhost file for my main site:

    ServerAlias *.<mydomain>.com

    to see if that made a difference. With this line missing the subdomains no longer point at the homepage of my main website. They point to the Apache test page you get when you've just set up Apache and not installed any site code.
    This is still the wrong destination as the subdomains' folders have automatically generated pages in them stating the sites name so it's likely that the subdomains are now all pointing at the default apache directory instead of their own directories.

    Could anyone post an example of a vhost file for a main site and one for a subdomain so I can check against what I have to see if it missed anything out or added something it didn't need?
     
  13. ivomendonca

    ivomendonca Banned

    SubDomain as Full Site or as Folder inside current ?

    If as folder you cant access using http://name.domain.tld (I cant)
    only work http://domain.tld/subdomain


    If as full website is possible to access - http://name.domain.tld

    Im not sure if is possible to create a folder as subdomain and access as http://name.domain.tld. is it ?
     
  14. fooboo

    fooboo New Member

    I've set up a whole new site as <subdomain>.<domain>.<tld>
    It has it's own set of folders and should just behave as a second site on my server but for some reason it still redirects to my main domain's homepage.

    The reason why I tried in subfolders of my main domain first is that is what I have done in the past with a hosting account I have. I host some sites with Site5.com and how their system works is you set one main domain and then you can use domain pointers to setup as many other domains as you want in subfolders.
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    1) Is your server behind a router?
    2) Did you select the IP address or * in the website settings?
     
  16. fooboo

    fooboo New Member

    Yes, I have a linksys router that port forwards all traffic on port 80 to this server.

    I selected the IP address.
     
  17. fooboo

    fooboo New Member

    I've just had a poke around (been a while since I set it up) and my server's IP is actually in the DMZ so there shouldn't be anything blocked.
     
  18. till

    till Super Moderator Staff Member ISPConfig Developer

    Make sure that you selected the internal IP adress for the website, the one that you forwarded port 80 to from your router, and not the external IP. IO've also seen that the dms does not work correctly sometimes, I had a linksys router too. The only solution was to forward port 80 in the router to the IP of the server and not using the dmz.
     
  19. fooboo

    fooboo New Member

    Huzzah! you're a genius. I was putting in the external IP address not the internal one (doh!). Once I switched to the internal one the sites switched to their correct folders.
    All bar one for which it either has some cached settings or I've screwed it up trying to sort the problem out as that still points at the default apache folder (at least it's not my home page :p).

    I've noticed if I delete the site and then recreate it I don't get a new fresh site it just recreates the old broken one so I'm guessing ISPConfig stores the details in a db and just reuses them?
     
  20. till

    till Super Moderator Staff Member ISPConfig Developer

    No. If you delete a site in ispconfig, it gets removed from the DB too.
     

Share This Page