
21st April 2005, 18:36
|
|
Junior Member
|
|
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Subdomains and Apache
A quick newbie-question: how do you set up subdomains in Apache? What I want to do is this:
I have a web site www.domain.com. Now I want to create a subdomain sub.domain.com, and when I enter it in my browser, I want to go to the same web site ( www.domain.com).
RedStar
|

22nd April 2005, 11:47
|
|
Junior Member
|
|
Join Date: Apr 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You can do it with the ServerAlias directive. A little example:
Code:
<VirtualHost aaa.bbb.ccc.ddd>
ServerName www.domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /path/to/your/document_root
ServerAlias sub.domain.com
</VirtualHost>
Jojo
|

27th May 2006, 11:40
|
|
Junior Member
|
|
Join Date: May 2006
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
|
|
hm...i have a question here ...
i found on net a similar code with the one gived by jojo
Code:
Listen 80
NameVirtualHost *
<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>
<VirtualHost *>
ServerName subdomain.domain.com
DocumentRoot /home/httpd/htdocs/subdomain/
</VirtualHost>
and i'm sure that it's gonna work ...
but now a noomb question  .... where do i paste this code in httpd.conf ?
The begining of my httpd.conf looks like this ( i won't paste all file it's to large ) :
Code:
Listen 80
ServerRoot "/www/Apache2"
DocumentRoot "/www/webroot"
ServerName localhost:80
ServerAdmin admin@localhost
ServerSignature On
ServerTokens Full
DefaultType text/plain
AddDefaultCharset ISO-8859-1
Can anybody show me how should i modify the file ?
That's all  Thanq
ps : and another noomb question  .... witch of this two codes is better ?
|
|
The Following User Says Thank You to Dutzzu For This Useful Post:
|
|

27th May 2006, 14:34
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
|
|
Quote:
|
Originally Posted by Dutzzu
but now a noomb question  .... where do i paste this code in httpd.conf ?
|
This normally goes near the end of your httpd.conf. There should be an example section about virtual hosts. But it might also be in some included file. Which distribution do you use?
Quote:
|
Originally Posted by Dutzzu
ps : and another noomb question  .... witch of this two codes is better ?
|
They do pretty much the same.
|

27th May 2006, 22:52
|
|
Junior Member
|
|
Join Date: May 2006
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
|
|
First of all than'q for answering me falko
Now ... i've got the apache instalation from http://www.devside.net/web/server/free/download ( setup 1.16 ) ...
And about httpd.conf file ... it doesn't have any exemple ... i think it's not a very popular version of apache  in all forums i looked the httpd.conf file looks different  I hope that's not a problem
I think it's easyer if i put the file ... and if u have time & wish to help me ... to solve it easyer . So here's the file
And about the exemple u saied that it should be ... i found one in other file ( witch is in the same folder with httpd.conf ) named " httpd.default.conf " ... it has a lil' example at the end of the file .... here'is the file If this is what i searched i have to delet " # " before the example and replace it with the code i entered in first message ?
Thank you again for your time
Last edited by Dutzzu; 27th May 2006 at 23:11.
|

28th May 2006, 23:49
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
|
|
I'd put
Code:
Listen 80
NameVirtualHost *
<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>
<VirtualHost *>
ServerName subdomain.domain.com
DocumentRoot /home/httpd/htdocs/subdomain/
</VirtualHost>
at the end of your httpd.conf and restart Apache.
|

29th May 2006, 10:30
|
|
Senior Member
|
|
Join Date: Mar 2006
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
must i change some dns record for subdomain? or just edit httpd.conf
|

29th May 2006, 16:51
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
|
|
Your DNS records for the subdomains must point to the correct IP address.
|

4th June 2006, 21:59
|
|
Junior Member
|
|
Join Date: May 2006
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Should i delete something from the start of the document ? or just paste that code at the end ?
|

5th June 2006, 15:25
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,853
Thanks: 781
Thanked 1,558 Times in 1,477 Posts
|
|
Paste the code at the end and comment out those directives if they are somewhere else in the file.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 06:56.
|
Recent comments
22 hours 24 min ago
1 day 3 hours ago
1 day 3 hours ago
1 day 3 hours ago
1 day 5 hours ago
1 day 7 hours ago
1 day 9 hours ago
1 day 9 hours ago
1 day 10 hours ago
1 day 11 hours ago