Apache2 - Virtual Host redirect problem with multiple domains
Hi, looking for a bit of help with Apache2 on Ubuntu Desktop.
I have 2 names : example1.com and example2.com but having problems with redirecting. If I type www.example1.com I get my homepage for Example 1 If I type example1.com I get Example 1 homepage again If I type www.example2.com I get my homepage for Example 2 now the problem here is If I type example2.com it takes me to Example 1 homepage. I have this in /etc/apache2/apache2.conf at the very bottom : # Include the virtual host configurations: Include sites-enabled/ <VirtualHost *:80> DocumentRoot /Websites/example1 ServerName example1.com <Directory "/Websites/example1"> allow from all Options +Indexes </Directory> ServerAlias *.example1.com </VirtualHost> <VirtualHost *:80> DocumentRoot /Websites/example2 ServerName example2.com <Directory "/Websites/example2"> allow from all Options +Indexes </Directory> ServerAlias *.example2.com </VirtualHost> Does any one have a solution for me on this. I've tried many things but still not working correctly. I have my DNS set up on Fasthosts for each domain in A records (www) pointing to my ip address for each domain. Thank you for any help. Kevin |
Hi,
You need: Code:
ServerAlias *.example2.com example2.com Regards |
Hi, Thanks for your reply but it still does not work.
It still goes to the example1 homepage. Kevin |
Quote:
Then you need to clear your browser cache (or use another browser) to do your tests. Regards |
Hi,
Yes I did sudo /etc/init.d/apache2 reload and sudo /etc/init.d/apache2 restart Still no go. I've tried many different ways from google search but always ends up been the same. Kevin |
I'm not familiar with the apache installation in ubuntu, but I think you use apache2 instead of httpd. If that's the case, run
Code:
apache2 -S May I ask why don't you use the default ubuntu way to define vhosts? Meaning you have to use /etc/apache2/sites-enabled/blah to configure and a2ensite to enable vhosts |
Hi, thanks for your replies.
I set the two servers up using webmin and it set the apache2.conf like that. I have now used your suggestion to use /sites-enabled/000-default But still have the same problem. I am using the server from a Virtual machine on my iMac. I changed my host file on mac to 192.168.1.100 for www.example.com/example.com www.example1.com/example1.com and obviously that works fine for redirecting its just if I try the addresses on my macbook using a different wifi connection not connected to my network in anyway I get the redirect problem. Thanks for your help. Kevin |
Quote:
VirtualHost configuration: 192.168.1.103:80 is a NameVirtualHost default server melvincloud.com (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost melvincloud.com (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost photo-revive.com (/etc/apache2/sites-enabled/000-default:12) Syntax OK |
Quote:
From here both domains above resolve to the same IP (88.208.x.x), while both subdomains with the www prefix resolve to a different IP (94.168.x.x) |
Quote:
exchange 213.171.192.xxx mail 213.171.216.xxx mailserver 213.171.216.xxx mcp 213.171.195.xxx smtp 213.171.216.xxx webmail 213.171.216.xxx 88.208.xxx.xxx www 94.168.xxx.xxx I have web forwarding set-up as http://94.168.250.xxx Is this correct or do I need to remove the 88.208.xxx.xxx which has no prefix on it ? Sorry for been a pain. Benn trying for days to resolve this. Kevin |
Quote:
|
Hi,
I have changed 88.208.xxx.xxx www 94.168.xxx.xxx to : 94.168.xxx.xxx www 94.168.xxx.xxx on both of the DNS settings page on Fasthosts control panel but getting same. Think i'm going to give up on it now. I'm going round in circles trying to fix it. :) Even if I switch the VirtualHost in /etc/apache2/sites-available/default file so example2.com is the first entry it all reverses with same problem. Thanks. Kevin |
You need to define the default "website" as a vhost also. I'm talking about the setup in apache httpd.conf where you have ServerName and so on. You have 2 vhosts and the default setup so you need to have 3 vhosts.
|
Quote:
ServerName localhost in my httpd.conf file. How would I go about doing this if you dont mind. |
Create a vhost with localhost and DocumentRoot as it's set by default in the httpd.conf
You dont need ServerAlias for this. Code:
<VirtualHost *:80> |
All times are GMT -5. The time now is 05:49 PM. |