
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] Multiple Domains - Apache
On Tuesday 29 April 2008 08:34:51 Deepan wrote:
> I am serving two domains from the same machine
> using Apache. I want www to be used in both of the
> domains, hence I redirect urls without www to
> appropriate urls with www.
I would suggest using Redirect instead of RewriteEngine. For example:
<VirtualHost *:80>
ServerName www.domaina.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www/domaina/
<Directory /var/www/domaina/>
Options FollowSymLinks
AllowOverride None
Order Allow,Deny
Allow from All
</Directory>
ErrorLog /var/log/apache2/domaina.error.log
LogLevel warn
CustomLog /var/log/apache2/domaina.access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName domaina.com
Redirect permanent / http://www.domaina.com/
</VirtualHost>
Then make a copy for the second domain. With your cursor on the last line in
vi:
:1,.y
p
:.,$s/domaina/domainb/
Some people have suggested the use of ServerAlias. Note, however, that this
causes the same content to be served for both addresses, not a redirect,
which is what you said that you want (and is usually a better practice). If
you had a .org domain that you wanted to redirect as well, though, then
ServerAlias would be used. The second VirtualHost above would become the
following:
<VirtualHost *:80>
ServerName domaina.com
ServerAlias www.domaina.org
ServerAlias domaina.org
Redirect permanent / http://www.domaina.com/
</VirtualHost>
Hope this helps,
Travis
Home |
Main Index |
Thread Index