I'm trying to use a skip rule after a RewriteCond, but then the
conditions are not checked.

I've got these rewrite rules:

        RewriteCond %{REQUEST_URI} \.(jpe?g|gif|png|txt|doc|ppt|pdf)$
        RewriteCond %{REQUEST_URI} !/css/
        RewriteRule ^/(.+)$ /domains/default/$1             [last]

The goal is for any for those file types to rewrite the path.  This
works fine and the log shows:

    init rewrite engine with requested uri /foo.txt
    applying pattern '^/(.+)$' to uri '/foo.txt'
    RewriteCond: input='/foo.txt' pattern='\.(jpe?g|gif|png|txt|doc|ppt|pdf)$' 
=> matched
    RewriteCond: input='/foo.txt' pattern='!/css/' => matched
    rewrite /foo.txt -> /domains/default/foo.txt
    local path result: /domains/default/foo.txt



Now the problem.  When there's a path prefix of "Rural" then I want
to not rewrite to /domains/default but rather to /domains/Rural.

So this is my attempt:

        RewriteCond %{REQUEST_URI} \.(jpe?g|gif|png|txt|doc|ppt|pdf)$
        RewriteCond %{REQUEST_URI} !/css/

        RewriteRule ^/Rural - [skip=1,nocase]
        RewriteRule ^/(.+)$ /domains/default/$1             [last]
        RewriteRule ^/(?:Rural/)?(.+)$ /domains/Rural/$1    [last,nocase]

So, the idea is if it matches /Rural it skips a rule and uses the
last rule to rewrite to /domains/Rural.  Otherwise it rewrites to 
/domains/default.

But when I do this the RewriteCond no longer is matched for /foo.txt:

    init rewrite engine with requested uri /foo.txt
    applying pattern '^/Rural' to uri '/foo.txt'
    applying pattern '^/(.+)$' to uri '/foo.txt'
    rewrite /foo.txt -> /domains/default/foo.txt
    local path result: /domains/default/foo.txt
    prefixed with document_root to 
/home/moseley/WS2/root/domains/default/foo.txt
    go-ahead with /home/moseley/WS2/root/domains/default/foo.txt [OK]

but is for /Rural/foo.txt


    init rewrite engine with requested uri /Rural/foo.txt
    applying pattern '^/Rural' to uri '/Rural/foo.txt'
    RewriteCond: input='/Rural/foo.txt' 
pattern='\.(jpe?g|gif|png|txt|doc|ppt|pdf)$' => matched
    RewriteCond: input='/Rural/foo.txt' pattern='!/css/' => matched
    applying pattern '^/(?:Rural/)?(.+)$' to uri '/Rural/foo.txt'
    rewrite /Rural/foo.txt -> /domains/Rural/foo.txt
    local path result: /domains/Rural/foo.txt
    prefixed with document_root to /home/moseley/WS2/root/domains/Rural/foo.txt
    go-ahead with /home/moseley/WS2/root/domains/Rural/foo.txt [OK]

It's vaguely familiar that it's a problem with how the RewriteCond
fires after the RewriteRule.

Am I not remembering how skip works?  Can I not use RewriteCond this
way?



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]








-- 
Bill Moseley
[EMAIL PROTECTED]


---------------------------------------------------------------------
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: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to