[Apache2] Creating subdomains

Glaanieboy

OSNN Veteran Addict
Joined
6 Mar 2002
Messages
2,628
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!
 
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>
 
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*
 
hrmm dunno what to tell you then

afaik its just down to the NameVirtualHost and <VirtualHost> blocks and it should work
 
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.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back