Re: 'redirect' to a single domain name

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

 



On Fri, Mar 16, 2012 at 12:25 PM, Lester Caine <lester@xxxxxxxxxxx> wrote:
> OK ... I've always set the server up so that both xxx.co.uk and
> www.xxx.co.uk are processed, but the 'quality police' are now flagging this
> as wrong, and saying that one or the other should be 'returned' by the site.
> Since some sites also have xxx.com or other options this does make sense,
> the question is how?
>
> I'm already using rewrite to keep the wingers happy on 'tidy url's' and that
> works well, and if I am readying things correctly 'Redirect' should handle
> the domain? But it does not seem to work. I assume that this needs to be
> handled inside the <VirtualHost> for it to correctly map what is listed in
> the ServerAlias to match the ServerName entry?
>
> What IS the politically correct way of handling this?
>

I know of two ways :)

1) Use two vhosts and a redirect:

<VirtualHost *>
  ServerName www.canonicalsitename.com
</VirtualHost>

<VirtualHost *>
  ServerName analias.canonicalsitename.com
  ServerAlias *.canonicalsitename.com
  Redirect / http://www.canoncialsitename.com/
</VirtualHost>

2) Use one vhost and a rewrite rule:

<VirtualHost *>
  ServerName www.canonicalsitename.com
  ServerName analias.canonicalsitename.com
  ServerAlias *.canonicalsitename.com
  RewriteCond %{HTTP_HOST} !^www.canonicalsitename.com$
  RewriteRule ^/(.*) http://www.canonicalsitename/$1 [R=301,L]
</VirtualHost>

Tapped all that out, and THEN remembered that this is a FAQ:

http://httpd.apache.org/docs/2.2/rewrite/remapping.html#canonicalhost

Cheers

Tom

PS: the same Lester Caine who posts on the register boards?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-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