• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

[Apache2] Creating subdomains

#1
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
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
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*
 
#5
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

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,240
Members
89,015
Latest member
loxioalix