You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Lester Caine <le...@lsces.co.uk> on 2012/03/16 13:25:51 UTC

[users@httpd] 'redirect' to a single domain name

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?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 'redirect' to a single domain name

Posted by Lester Caine <le...@lsces.co.uk>.
Lester Caine wrote:
> Tom Evans wrote:
>> Tapped all that out, and THEN remembered that this is a FAQ:
>> http://httpd.apache.org/docs/2.2/rewrite/remapping.html#canonicalhost
> TA ...

Problem solved :)
Helps if you edit the .co.uk record rather than the .org.uk one

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 'redirect' to a single domain name

Posted by Lester Caine <le...@lsces.co.uk>.
Tom Evans wrote:
> Tapped all that out, and THEN remembered that this is a FAQ:
> http://httpd.apache.org/docs/2.2/rewrite/remapping.html#canonicalhost
TA ...

> PS: the same Lester Caine who posts on the register boards?
Probably :) Don't get much time to read the news these days ...

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 'redirect' to a single domain name

Posted by Tom Evans <te...@googlemail.com>.
On Fri, Mar 16, 2012 at 12:25 PM, Lester Caine <le...@lsces.co.uk> 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@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org