httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Moseley <mose...@hank.org>
Subject Re: [users@httpd] Help with mod_rewrite rules
Date Fri, 11 Aug 2006 00:45:50 GMT
On Thu, Aug 10, 2006 at 08:38:32PM -0400, Joshua Slive wrote:
> On 8/10/06, Bill Moseley <moseley@hank.org> wrote:
> >I suppose the simple way is the following:
> >
> >        RewriteCond %{REQUEST_URI} \.(jpe?g|gif|png|txt|doc|ppt|pdf)$
> >        RewriteCond %{REQUEST_URI} !/css/
> >        RewriteCond %{REQUEST_URI} ^/Rural                  [nocase]
> >        RewriteRule ^/(?:Rural/)?(.+)$ /domains/Rural/$1    [last,nocase]
> >
> >        # now non-rural, do the same.
> >
> >        RewriteCond %{REQUEST_URI} \.(jpe?g|gif|png|txt|doc|ppt|pdf)$
> >        RewriteCond %{REQUEST_URI} !/css/
> >        RewriteRule ^/(.+)$ /domains/default/$1             [last]
> 
> RewriteConds apply only to the RewriteRule immediately following them.
> There are various ways to avoid having to write the same conds
> multiple times, for example:
> RewriteCond %{REQUEST_URI} !\.(jpe?g|gif|png|txt|doc|ppt|pdf)$
> RewriteCond %{REQUEST_URI} ^/css/
> RewriteRule .* - [L]
> 
> RewriteRule ^/(.+)$ /domains/default/$1             [last]
> RewriteRule ^/(?:Rural/)?(.+)$ /domains/Rural/$1    [last,nocase]

I see.  I was thinking the Skip feature wouldn't really count. ;)

I build the httpd.conf with templates so it's not much problem
repeating.

I also realized that only .html needs to get proxied to my backend,
so I can just look for any files with an extension that doesn't end
in .html:

        RewriteCond %{REQUEST_URI} !/css/
        RewriteCond %{REQUEST_URI} \.\w+$
        RewriteCond %{REQUEST_URI} !\.html$
        RewriteRule ^/(.+)$ /domains/default/$1             [last]

Thanks!

-- 
Bill Moseley
moseley@hank.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