On Fri, Jan 9, 2009 at 6:26 AM, Anders Norrbring <[email protected]> wrote:
> Hi.
> I'm looking at a setup with 6 different ServerAlias in the same single
> VirtualHost, and I want a rewrite rule that can rewrite calls missing the
> 'www' part to add that.
>
> Looking at example pages I see that this works for a single host name:
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} !^www\.domain\.tld [NC]
> RewriteCond %{HTTP_HOST} !^$
> RewriteRule ^/(.*) http://www.domain.tld/$1 [L,R]
>
> But how can I create a setup that will simple add www to any of the valid
> ServerAlias names listed in the virtual host? They shall keep the domain
> name part as is, and not rewrite to one name only.
>
> Eg.
> server1.com should be www.server1.com
> sdom.org should be www.sdom.org
> etc...
>
> Thank you for your ideas!
> Anders.
Anders,
Have you considered doing the opposite, dropping the www subdomain?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Thanks to http://no-www.org/
Bruce
---------------------------------------------------------------------
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: [email protected]
" from the digest: [email protected]
For additional commands, e-mail: [email protected]