RE: rewrite rule ideas needed..

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

 



It may be simplistic, but I do this with a second VirtualHost.

<VirtualHost *>
ServerName www.mydomain.com
DocumentRoot /foo/bar
</VirtualHost>

<VirtualHost *>
ServerName mydomain.com
Redirect / http://www.mydomain.com/
</VirtualHost>

Since my SSL certificate is configured only for the www version of my URL, I
have to make sure that no matter which URL they use to enter the site, they
are immediately redirected to the www version of that URL. Including the /
on the end of the Redirect domain allows my server to also handle requests
directly to subpages & subdirectories with the non-www address, ensuring
that those URL are rewritten as well. But this can become tedious if you
have a large number of URLs that you need to do this for. 

-----Original Message-----
From: Bob Ionescu [mailto:bobsiegen@xxxxxxxxxxxxxx] 
Sent: Friday, January 09, 2009 6:34 AM
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  rewrite rule ideas needed..

2009/1/9 Anders Norrbring <lists@xxxxxxxxxxxx>:
> 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.

Have a look at the last example of the section "Canonical Hostnames":
http://httpd.apache.org/docs/trunk/rewrite/rewrite_guide.html#canonicalhost

But make sure, you're sending a 301 redirect (R=301) for search engines.

Bob

---------------------------------------------------------------------
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


---------------------------------------------------------------------
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