Jump to content

Recommended Posts

I have two domain on my server. I configured BIND DNS and two virtual host on apache server for them.

 

The first domain works well, but when browsing the second domain, it shows the content of first apache virtual host, instead of the second one with the name of the second domain.  :(

Link to comment
https://forums.phpfreaks.com/topic/151545-solved-bind-and-apache-virtual-host/
Share on other sites

It's a long file on /etc/httpd/conf

 

I think you mean the last part, which is

 

<VirtualHost 200.35.149.48>

DocumentRoot "/var/www/html/site1"

<Directory "/var/www/html/site1">

allow from all

Options +Indexes

</Directory>

</VirtualHost>

<VirtualHost 200.35.149.48>

DocumentRoot "/var/www/html/site2"

<Directory "/var/www/html/site2">

allow from all

Options +Indexes

</Directory>

</VirtualHost>

You need to be using name based virtual hosts.

 

 

 

Basic example:

 

 

NameVirtualHost *:80

<VirtualHost *:80>

ServerName domain1.tld

DocumentRoot "/path/to/doc/root/"

</VirtualHost>

 

<VirtualHost *:80>

ServerName domain2.tld

DocumentRoot "/path/to/doc/root2/"

</VirtualHost>

Sorry for this, but the problem still persists :(

 

The httpd.conf now looks like

 

<VirtualHost *:80>

DocumentRoot /var/www/html/site1

<Directory "/var/www/html/site1">

allow from all

Options +Indexes

</Directory>

ServerName www.site1.com

</VirtualHost>

<VirtualHost *:80>

DocumentRoot /var/www/html/site2

<Directory "/var/www/html/site2">

allow from all

Options +Indexes

</Directory>

ServerName www.site2.com

</VirtualHost>

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.