Reputation: 3067
I created 2 virtual hosts http:// web1.com:2107 pointing to "/var/www/web1" folder and second http:// web2.com:2107 pointing to "/var/www/web2". all subdomains in web2 are working fine, But in case of web1.com:2107 i am able to see only home page. when i try to open any subdomain from web1 like http:// games.web1.com:2107 it points to web2's home page ie /var/www/web2/ directory
Is there anything wrong in configuration ?
below is the code for hosts i am using
<VirtualHost *:80>
ServerName web2.com
ServerAdmin [email protected]
ServerAlias http://www.web2.com
DocumentRoot /var/www/web2
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/web2>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/www/web2/error80.log
CustomLog /var/www/web2/access80.log Combined
</VirtualHost>
<VirtualHost *:2107>
ServerName web2.com
ServerAdmin [email protected]
ServerAlias http://www.web2.com
DocumentRoot /var/www/web2
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/web2>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/www/web2/error.log
CustomLog /var/www/web2/access80.log Combined
LogLevel warn
CustomLog /var/log/apache2/web2.com_access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
===================================================================
NameVirtualHost *:2107
<VirtualHost *:2107>
ServerName web1.com
ServerAlias http://web1.com
DocumentRoot /var/www/web1
<Directory /var/www/web1/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
ErrorLog /var/www/web1/error.log
CustomLog /var/www/web1/access.log Combined
</VirtualHost>
Upvotes: 3
Views: 13304
Reputation: 773
For Cloudflare users wich have some issues with SSL and a wrong directory:
Change the SSL Mode at Crypto from Flexible
to Full
.
This helped me.
Upvotes: 0
Reputation: 30496
When you have several VirtualHosts one of them is the default VirtualHost. It's the first one in alphabetic order of the file containing the definition of the VirtualHost.
When you remove a VirtualHost. If you still have an entry in the Hosts file or a DNS record, when the query is performed on your Apache server, if it cannot find the right VirtualHost (ServerName or ServerAlias), then the default one is taken to process the answer.
When you add a new VirtualHost, if you make a mistake in the ServerName or ServerAlias you'll also have the default VH.
Update
Now that the question is complete I can see you are not using ServerAlias in the right way. All your subdomains should be listed in ServerAlias directives, without the http:// So you should have:
ServerName web1.com
ServerAlias www.web1.com
ServerAlias games.web1.com
You could maybe try a *.web1.com. Else when you use a name which is not listed the default vhost is used (and here vhost web2.com is defined before so it's the default one on this port)
Upvotes: 6
Reputation: 3067
Well i got the problem half, there was entry left behind in HOSTS file so that page was still available with deleted host name entry. Now the half problem still there. now i created one more host entry and pointed to diff location but still its pointing to old location :(
Upvotes: 0
Reputation: 4233
After you change an Apache Conf, you have to restart the service. Not sure if that was the problem, but it never hurts to check ;)
Upvotes: 0