You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "J. Bakshi" <jo...@infoservices.in> on 2009/03/27 10:35:06 UTC
[users@httpd] domain mixed up problem
Dear list,
I have a remote server with 2 different domain pointing to the same
server. I have configured some vhosts for these 2 domains. But I have
found that the vhosts are working for both the domains. For an example
say I have two domains domain1.com and domain2.com
Now two vhosts are site1.domain1.com and site2.domain2.com
Now if you exchange the domains like site1.domain2.com it still works as
before ( site1.domain1.com )
How can I restrict this behavior so that site1.domain1.com works but
site1.domain2.com not ?
Here are my vhost configuration
## site1 on domain1
NameVirtualHost site1.domain1.com:80
<VirtualHost site1.domain1.com:80>
ServerName http://www.site1.domain1.com
ServerAlias http://ble.site1.domain1.com
DocumentRoot /srv/www/htdocs/site1
DirectoryIndex index.php
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
<Directory "/srv/www/htdocs/site1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Options None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
## site2 on domain2
NameVirtualHost site2.domain2.com:80
<VirtualHost site2.domain2.com:80>
ServerName http://www.site2.domain2.com
ServerAlias http://site2.domain2.com
DocumentRoot /srv/www/htdocs/site2
DirectoryIndex index.php
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
<Directory "/srv/www/htdocs/site2/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Options None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] domain mixed up problem
Posted by "J. Bakshi" <jo...@infoservices.in>.
J. Bakshi wrote:
Hello,
I have found the problem. "apachectl -S" shows that domain.1 has ben
taken as default server. hence it automatically goes to the default one
when It can't match the url. I have created another vhost configuration
file which is named as a.conf and in that file I have configured to
read an index.php file which simply shows "nothing to see here". I have
named it as a.conf as apache make the configuration as default server
whose configuration it gets first (as alphabetically). Now this a.conf
has become the default server and when ever I put any wrong
subdomain.domain combination it shows "nothing to see here".
Bye
> Dear list,
>
> I have a remote server with 2 different domain pointing to the same
> server. I have configured some vhosts for these 2 domains. But I have
> found that the vhosts are working for both the domains. For an example
> say I have two domains domain1.com and domain2.com
>
> Now two vhosts are site1.domain1.com and site2.domain2.com
>
> Now if you exchange the domains like site1.domain2.com it still works as
> before ( site1.domain1.com )
> How can I restrict this behavior so that site1.domain1.com works but
> site1.domain2.com not ?
>
> Here are my vhost configuration
>
> ## site1 on domain1
> NameVirtualHost site1.domain1.com:80
>
> <VirtualHost site1.domain1.com:80>
> ServerName http://www.site1.domain1.com
> ServerAlias http://ble.site1.domain1.com
>
> DocumentRoot /srv/www/htdocs/site1
>
> DirectoryIndex index.php
>
> ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
> <Directory "/srv/www/htdocs/site1/">
> Options Indexes FollowSymLinks MultiViews
> AllowOverride All
> Options None
> Order allow,deny
> Allow from all
> </Directory>
> </VirtualHost>
>
> ## site2 on domain2
> NameVirtualHost site2.domain2.com:80
>
> <VirtualHost site2.domain2.com:80>
> ServerName http://www.site2.domain2.com
> ServerAlias http://site2.domain2.com
>
> DocumentRoot /srv/www/htdocs/site2
>
> DirectoryIndex index.php
>
> ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
> <Directory "/srv/www/htdocs/site2/">
> Options Indexes FollowSymLinks MultiViews
> AllowOverride All
> Options None
> Order allow,deny
> Allow from all
> </Directory>
> </VirtualHost>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] domain mixed up problem
Posted by "J. Bakshi" <jo...@infoservices.in>.
Tom Evans wrote:
> On Fri, 2009-03-27 at 15:05 +0530, J. Bakshi wrote:
>
>> Dear list,
>>
>> I have a remote server with 2 different domain pointing to the same
>> server. I have configured some vhosts for these 2 domains. But I have
>> found that the vhosts are working for both the domains. For an example
>> say I have two domains domain1.com and domain2.com
>>
>> Now two vhosts are site1.domain1.com and site2.domain2.com
>>
>> Now if you exchange the domains like site1.domain2.com it still works as
>> before ( site1.domain1.com )
>> How can I restrict this behavior so that site1.domain1.com works but
>> site1.domain2.com not ?
>>
>> Here are my vhost configuration
>>
>> ## site1 on domain1
>> NameVirtualHost site1.domain1.com:80
>>
>> <VirtualHost site1.domain1.com:80>
>> ServerName http://www.site1.domain1.com
>> ServerAlias http://ble.site1.domain1.com
>>
>> DocumentRoot /srv/www/htdocs/site1
>>
>> DirectoryIndex index.php
>>
>> ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
>> <Directory "/srv/www/htdocs/site1/">
>> Options Indexes FollowSymLinks MultiViews
>> AllowOverride All
>> Options None
>> Order allow,deny
>> Allow from all
>> </Directory>
>> </VirtualHost>
>>
>> ## site2 on domain2
>> NameVirtualHost site2.domain2.com:80
>>
>> <VirtualHost site2.domain2.com:80>
>> ServerName http://www.site2.domain2.com
>> ServerAlias http://site2.domain2.com
>>
>> DocumentRoot /srv/www/htdocs/site2
>>
>> DirectoryIndex index.php
>>
>> ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
>> <Directory "/srv/www/htdocs/site2/">
>> Options Indexes FollowSymLinks MultiViews
>> AllowOverride All
>> Options None
>> Order allow,deny
>> Allow from all
>> </Directory>
>> </VirtualHost>
>>
>>
>>
>
> Apache will serve any request that it receives. With vhosts, it tries to
> find one matching the host header of the request. If one is not found,
> it will serve the first vhost listed in the conf.
>
> So, either dont let site2.domain1.com resolve to this server, or have a
> default 'error' vhost appear first in your config file.
>
> Tom
>
Hello Tom,
I have just posted how I have fixed it. I have followed the same
approach as you have mentioned.
Have a nice day,
Thanks
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] domain mixed up problem
Posted by Tom Evans <te...@googlemail.com>.
On Fri, 2009-03-27 at 15:05 +0530, J. Bakshi wrote:
> Dear list,
>
> I have a remote server with 2 different domain pointing to the same
> server. I have configured some vhosts for these 2 domains. But I have
> found that the vhosts are working for both the domains. For an example
> say I have two domains domain1.com and domain2.com
>
> Now two vhosts are site1.domain1.com and site2.domain2.com
>
> Now if you exchange the domains like site1.domain2.com it still works as
> before ( site1.domain1.com )
> How can I restrict this behavior so that site1.domain1.com works but
> site1.domain2.com not ?
>
> Here are my vhost configuration
>
> ## site1 on domain1
> NameVirtualHost site1.domain1.com:80
>
> <VirtualHost site1.domain1.com:80>
> ServerName http://www.site1.domain1.com
> ServerAlias http://ble.site1.domain1.com
>
> DocumentRoot /srv/www/htdocs/site1
>
> DirectoryIndex index.php
>
> ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
> <Directory "/srv/www/htdocs/site1/">
> Options Indexes FollowSymLinks MultiViews
> AllowOverride All
> Options None
> Order allow,deny
> Allow from all
> </Directory>
> </VirtualHost>
>
> ## site2 on domain2
> NameVirtualHost site2.domain2.com:80
>
> <VirtualHost site2.domain2.com:80>
> ServerName http://www.site2.domain2.com
> ServerAlias http://site2.domain2.com
>
> DocumentRoot /srv/www/htdocs/site2
>
> DirectoryIndex index.php
>
> ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
> <Directory "/srv/www/htdocs/site2/">
> Options Indexes FollowSymLinks MultiViews
> AllowOverride All
> Options None
> Order allow,deny
> Allow from all
> </Directory>
> </VirtualHost>
>
>
Apache will serve any request that it receives. With vhosts, it tries to
find one matching the host header of the request. If one is not found,
it will serve the first vhost listed in the conf.
So, either dont let site2.domain1.com resolve to this server, or have a
default 'error' vhost appear first in your config file.
Tom
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org