Re: rewrite rule ideas needed..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 9, 2009 at 6:26 AM, Anders Norrbring <lists@xxxxxxxxxxxx> 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: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux