Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

'redirect' to a single domain name

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


lester at lsces

Mar 16, 2012, 5:25 AM

Post #1 of 4 (372 views)
Permalink
'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 [at] httpd
For additional commands, e-mail: users-help [at] httpd


tevans.uk at googlemail

Mar 16, 2012, 5:38 AM

Post #2 of 4 (355 views)
Permalink
Re: 'redirect' to a single domain name [In reply to]

On Fri, Mar 16, 2012 at 12:25 PM, Lester Caine <lester [at] lsces> 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 [at] httpd
For additional commands, e-mail: users-help [at] httpd


lester at lsces

Mar 16, 2012, 5:48 AM

Post #3 of 4 (351 views)
Permalink
Re: 'redirect' to a single domain name [In reply to]

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 [at] httpd
For additional commands, e-mail: users-help [at] httpd


lester at lsces

Mar 16, 2012, 6:44 AM

Post #4 of 4 (348 views)
Permalink
Re: 'redirect' to a single domain name [In reply to]

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 [at] httpd
For additional commands, e-mail: users-help [at] httpd

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.