httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin French <jus...@indent.com.au>
Subject Re: [users@httpd] rewriting all domain.com to www.domain.com
Date Wed, 28 Aug 2002 11:23:16 GMT
on 28/08/02 7:13 PM, James Eastwood (JamesEastwood@businessserve.co.uk)
wrote:

> you could try this..
> 
> RewriteEngine on 
> RewriteCond %{HTTP_HOST}
> (^[a-z0-9\-]*)\.(co|com|ltd|plc|org|net|ac|sh|uk|sch|gb|ie|be|ms|cc|st|eu|ws
> |ty|biz|info)($|\.)
> RewriteCond %{HTTP_HOST} !www\..*$
> RewriteRule ^.+$ http://www.%{HTTP_HOST} [R]

Sorry -- mustn't have been very clear.  I only need it to work for ONE
domain (eg indent.com.au | www.indent.com.au) *NOT* for a whole server.

In psuedo code (total rewrite newbie!!), I think I need:

if(HTTP_HOST *doesn't* start with "www") {
    capture everything after the domain (eg /dir/index.html)
    rewrite the URL as http://www.mydomain.com/<the capture>
} else {
    do nothing
}

and the opposite

if(HTTP_HOST *does* start with "www") {
    capture everything after the www. (eg domain.com/dir/script.html)
    rewrite the URL as http://<the capture>
} else {
    do nothing
}


Thanks in advance
Justin French



> -----Original Message-----
> From: Justin French [mailto:justin@indent.com.au]
> Sent: 28 August 2002 08:30
> To: users@httpd.apache.org
> Subject: [users@httpd] rewriting all domain.com to www.domain.com
> 
> 
> Hi,
> 
> I checked out the associated pages in the FAQ, but I think it's a little
> above my head.
> http://httpd.apache.org/docs/misc/FAQ.html#canonical-hostnames
> 
> I'd like to rewrite (ie, the physical URL changes in the browser) for all
> requests on domain.com to www.domain.com, via a .htaccess directive.
> 
> It'd also be interesting to see how it's done for vice-versa.
> 
> 
> TIA,
> 
> Justin French
> 
> 
> 
> ---------------------------------------------------------------------
> 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@httpd.apache.org
> "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message