Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Name Virtual Host httpd.conf Problem

Status
Not open for further replies.

flash8

Programmer
Sep 8, 2006
10
US
Hello Forum I have two websites on my server and I am trying to setup a NameVirtualHost. when you open a browser to connect to or the browser takes you to a web page named index of / the page also shows the two folders my websites are in, example.com and myothercompany.com. If you click on any of the two folders the site will open.

What I need is for the website to point to and open the index file.
Below is the commands I added to the httpd.conf
Thanks in advance

NameVirtualHost *

<VirtualHost *>

ServerName
DocumentRoot /home/
ServerAdmin webmaster@example.com

ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ common

</VirtualHost>



<VirtualHost *>

ServerName
DocumentRoot /home/
ServerAdmin webmaster@myothercompany.com

ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ common

</VirtualHost>
 
Where would I check to see if I have a Listen directive?

Thanks in advance
 
There should be a DirectoryIndex directive in httpd.conf which tell sapche what you want to use as the default index page:

Code:
DirectoryIndex index.html index.php

If you have it in the main section of httpd.conf it will be defined globally. If you place it within a vhost container it will only apply to that virtualhost. Apache will look for you indexes in the order you list them. So in this case if it doesn't find an index.html when it goes to that directory it will look for index.php

 
RhythmAce, the way I'm reading the original problem is that hitting the server yeilds the htdocs directory (default server) instead of the different VirtualHost documentroots below.

apachectl -configtest probably doesn't work under windows. Is there a Windows equivalent? It seems like the virtual hosts are not being recognized.

Flash8, did you restart apache after adding the virtualhosts?
 
I want to thank smah and RhythmAce for all your help. smah you got it I was not restarting apache after making changes. I ended up going to Apache's website and using there sample below.

Again Thanks for all the support.


NameVirtualHost *:80

<VirtualHost *:80>
ServerName ServerAlias domain.tld *.domain.tld
DocumentRoot /</VirtualHost>

<VirtualHost *:80>
ServerName DocumentRoot /</VirtualHost>
 
Sorry guys. You were right smah. I completely misread his problem. I thought he was seeing each domain's root directory being listed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top