httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Evans <tevans...@googlemail.com>
Subject Re: [users@httpd] Server-Variables in CondPattern of RewriteCond directive
Date Wed, 22 Apr 2009 15:11:30 GMT
On Wed, 2009-04-22 at 22:30 +0800, Basil Mohamed Gohar wrote:
> On 04/22/2009 10:17 PM, Eric Covener wrote:
> > On Wed, Apr 22, 2009 at 10:14 AM, Basil Mohamed Gohar
> > <abu_hurayrah@hidayahonline.org>  wrote:
> >    
> >>> Outside of htaccess, the pattern is compiled at startup, so you can't
> >>> use variables (because they depend on parts of the request, even
> >>> ServerName).
> >>>
> >>> IIUC It's feasible in per-directory, but not implemented.
> >>>
> >>>
> >>>        
> >> So, what this means is it's not possible as it stands right now, correct?
> >>      
> >
> > Correct. You can usually get to the same ultimate result by putting
> > the variables in the 2nd argument and being more clever with captures
> > and multiple conditions, etc.
> >
> > If you can describe what your end goal is, someone here might be able
> > to help construct a ruleset.
> >
> >    
> Thanks.  It's quite simple, actually.  What I want to do is direct all 
> domains that fall under a virtualhost which has many server aliases to 
> one canonical domain.
> 
> So, for example, if my canonical name is www.example.com, and someone 
> accesses example.com or example.net (all of which are aliases in 
> VirtualHost block), I want a redirect to be issued pointing to the 
> canonical ServerName value (www.example.com).  Since this is already 
> stored in %{SERVER_NAME}, I thought it would be best to use it, because 
> I have this kind of behavior on many, but not all, VirtualHosts.  It 
> would save me a lot of time.
> 

RewriteCond %{HTTP_HOST}  !^(www.foo.com)$
RewriteRule ^/(.*)        http://www.foo.com/$1 [R=301,L]

This is an FAQ iirc?

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

HTH

Tom



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