[Apache2] Creating subdomains

Discussion in 'Windows Desktop Systems' started by Glaanieboy, Dec 11, 2005.

  1. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I always thought creating a subdomain in Apache2 was as easy as adding the following line to the httpd.conf file (domain.nl is only an example)
    Code:
    <VirtualHost sub.domain.nl:80>
        ServerAdmin webmaster@sub.domain.nl
        DocumentRoot "C:/folder/subfolder"
        ServerName sub.domain.nl
        ErrorLog logs/sub.domain.nl-error_log
        CustomLog logs/sub.domain.nl-access_log common
    </VirtualHost>
    
    This conf doesn't work, I get a http 404 not found when going to sub.domain.nl, yet domain.nl still works. What the heck am I doing wrong? I already read about RewriteRules, but what I saw is that it may be a step too far for the simple thing I am trying to achieve, after all, VirtualHost was made for this kind of things, right? Can someone help me? Thanks!
     
  2. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    do you have NameVirtualHost *:80 set??

    btw I use this
    Code:
    <VirtualHost *:80>
            ServerName sub.domain.com
            DocumentRoot /path/to/sub/domain/public_html/
            ErrorLog /var/log/sub.domain.error.log
            CustomLog /var/log/sub.domain.access.log common
            <Directory "/path/to/sub/domain/public_html">
                    Options Indexes MultiViews
                    AllowOverride None
            </Directory>
    </VirtualHost>
    
     
  3. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I used your example (except for the <directory>...</directory> thing, I just use default), but still nothing. NameVirtualHost *:80 has been set and uncommented (I noticed there was still a # before it, I removed it and restarted Apache2, but still nothing). The directory-path is OK, it exists, has an dummy index.html file in it.
    *sigh*
     
  4. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    hrmm dunno what to tell you then

    afaik its just down to the NameVirtualHost and <VirtualHost> blocks and it should work
     
  5. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    O...K It's getting weird now. I have added a sub.domain.nl subdomain in my domain control panel at my registrar. Points to the same IP etc and it works now... But when I go to domain.nl, I see the contents of the subdomain! I am getting headaches now, I have no idea what I have done wrong... I'm gonna start all over again tomorrow afternoon, to retrace my steps where it went wrong.