Apache virtual host problem

first.com and forst.com have the same IP address and the server is using one apache 2.0.50.

If I uncomment the first.com virtual host, I cant access www.forst.com. If I access www.forst.com, I will get www.first.com.

If I put comment in first.com virtual host (like below), I can access www.forst.com correctly (but not www.first.com because disabled).

Anyone know how to fix this? So I can access both virtual host correctly ?


NameVirtualHost *:80

#<VirtualHost *:80>
# ServerAdmin webmaster@first.com
# DocumentRoot /home/www/first.com/html/
# ScriptAlias /cgi-bin/ /home/www/first.com/cgi-bin/
# ServerName main.first.com
# ErrorLog /home/www/first.com/logs/first.com-error_log
# CustomLog /home/www/first.com/logs/first.com-access_log "%h %l %t %>s %b %{Referer}i -> %U %q"

<VirtualHost *:80>
ServerAdmin webmaster@forst.com
DocumentRoot /home/www/forst.com/html/
ScriptAlias /cgi-bin/ /home/www/forst.com/cgi-bin/
ServerName main.forst.com
ErrorLog /home/www/forst.com/logs/forst.com-error_log
CustomLog /home/www/forst.com/logs/forst.com-access_log "%h %l %t %>s %b %{Referer}i -> %U %q"

Who is Participating?

Improve company productivity with a Business Account.Sign Up

ramazanyichConnect With a Mentor Commented:
You ServerName directives are worng.
It should be
ServerName www.first.com
for www.first.com 
ServerName www.forst.com

for www.forst.com

Check http://httpd.apache.org/docs-2.0/vhosts/name-based.html for details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.