LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   name based severs and subdomains - how to configure - apache2 (http://www.linuxquestions.org/questions/linux-server-73/name-based-severs-and-subdomains-how-to-configure-apache2-849788/)

twisteguy22 12-12-2010 04:46 PM

name based severs and subdomains - how to configure - apache2
 
hi all.

When I first encountered this problem, I though it would be a simple solution, but i must just be missing something obvious.

i have a few name based hosts configured in apache.

when i go to "www.adomainname.com" i get the first website on this list, not "adomainname.com", as i would like. Does anyone have any ideas on how to fix this?


here is the relevant part of my config files:

Code:

<VirtualHost *:80>
DocumentRoot "/var/www/httest"
ServerName hhexamplehh.selfip.com
<Directory "/var/www/httest">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName tempesthostingservices.com
DocumentRoot /var/www/tempest
<Directory /var/www/tempest/>
  allow from all
  Options +Indexes
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  AllowOverride All
  allow from all
  Options +Indexes
</Directory>
SetEnv SITE_ROOT /var/www/tempest
SetEnv SITE_HTMLROOT /var/www/tempest
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/var/www/brownstonehall"
ServerName brownstonehall.com
<Directory "/var/www/brownstonehall">
  AllowOverride All
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  allow from all
  Options +Indexes
</Directory>
#SetEnv SITE_ROOT /var/www/brownstonehall
#SetEnv SITE_HTMLROOT /var/www/brownstonehall
</VirtualHost>


bathory 12-12-2010 05:12 PM

Hi,

There is no www.adomainname.com vhost definition, so apache shows the default vhost (that is the 1st on the list)

twisteguy22 12-12-2010 05:32 PM

sorry, perhaps i was misleading in my OP.

i mean that if i go to any other domain name such as brownstonehall.com, it goes to the first vhost entry instead.

i am trying to make it so www.brownstonehall.com goes the the same place as brownstonehall.com.

is there any way to do that?

bathory 12-12-2010 05:48 PM

In that case you should use:
Code:

<VirtualHost *:80>
DocumentRoot "/var/www/brownstonehall"
ServerName brownstonehall.com
ServerAlias www.brownstonehall.com
...

Regards

twisteguy22 12-12-2010 08:00 PM

thank you very much.


All times are GMT -5. The time now is 01:52 PM.