#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    456
    Rep Power
    14

    DNS wildcard trick


    Hi, I don't know a whole lot about DNS, but I was hoping someone could instruct me how to do this, assuming it's possible. I currently have a DNS wildcard setup, but I would like to modify it a little bit.

    If someone visits http://www.domain.com or http://domain.com I would like the default page served to be index.htm

    If they visit http://anythingelse.domain.com I would like the default page served to be home.shtml.

    Other than the default page for the root web directory, I would like all other files to be served up exactly the same. So http://www.domain.com/directory/ would serve the index file as the default, and http://anythingelse.domain.com/directory/ would also serve the index file as the default. One should be able to view the same picture.jpg by going to http://www.domain.com/picture.jpg or http://anythingelse.domain.com/picture.jpg.

    So I guess what I want is a DNS wildcard with that one exception.

    Any help for me? THANKS!
  2. #2
  3. DNS/BIND Guru
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2003
    Location
    OH, USA
    Posts
    4,266
    Rep Power
    172
    The following assumes the different hosts you speak of are located on the same machine, same IP. If that is not the case, tell me:

    This doesn't have to do with DNS. What you want is to setup virtual hosts in the apache config. Setup a specific virtual host for index.htm. then setup a default virtual host for anything else to be home.htm.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    456
    Rep Power
    14
    The hosts are all on the same machine, same IP.
  6. #4
  7. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    16
    If someone visits http://www.domain.com or http://domain.com I would like the default page served to be index.htm

    If they visit http://anythingelse.domain.com I would like the default page served to be home.shtml.
    mod_rewrite can do this for you. Have a read of http://www.engelschall.com/pw/apache/rewriteguide/ for some tips.

    One should be able to view the same picture.jpg by going to http://www.domain.com/picture.jpg or http://anythingelse.domain.com/picture.jpg.
    In addition to setting up Apache with virtual hosts, you will need to create wildcard DNS records. I assume you already have this set up - in this case, this thread really belongs in the Apache forum as it is no longer specific to DNS.

    With regards to your Apache config, any subdomains that aren't explicitly assigned to a VirtualHost will be served by the first VirtualHost container in httpd.conf - so just make example.com the first VirtualHost, create the wildcard DNS records, and *.example.com will be served by that first VirtualHost.
    Last edited by alexgreg; June 20th, 2003 at 07:28 PM.
    Alex
    (http://www.alex-greg.com)
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    456
    Rep Power
    14
    Thanks, I got it working!

IMN logo majestic logo threadwatch logo seochat tools logo