httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@engelschall.com (Ralf S. Engelschall)
Subject mod_rewrite v2.2-SNAP
Date Tue, 06 Aug 1996 21:18:01 GMT

I don't know what the official status of inclusion of mod_rewrite into Apache
1.2-dev is. I think Alexei has this task on his side, but their were no "+1"
or "-1" votes for v2.1 to be included into the core distribution. 

Because of this still waiting decision, I couldn't sleep deeply last night
;-), because the currently released mod_rewrite v2.1 is good, yes. Good
enough I think to be included into the core distribution. But it had one(!)
feature (a lot of people wanted in the past) still not included, because I
thought it would be to hard to incorporate it into v2.1. So yesterday I
officially released v2.1 with this feature left on my TODO-List.

Today, I did a brainstorming again and realized that it is actually much
simpler to add as I thought in the past. Ok, long words, tiny semantics:

       mod_rewrite v2.2-SNAP now contains RULE PRECONDITIONS!

Hu? What's that? Let me show you an example of a possible .htaccess file:

  RewriteCond   %{HTTP_USER_AGENT}  ^Mozilla/3.*
  RewriteRule   ^testfile\.html$    testfile.max.html   [L]

  RewriteCond   %{HTTP_USER_AGENT}  ^Lynx.*             
  RewriteRule   ^testfile\.html$    testfile.min.html   [L]

  RewriteRule   ^testfile\.html$    testfile.std.html   [L]

With this (and without any CGI-stuff ;-) you can just rewrite a request to
.../somedir/testfile.html (assuming your .htaccess file was in "somedir" for
this example) depend of the Browser type. This is the standard example which
was wanted a lot by the users of mod_rewrite.

There is another real-world example, which come to my mind while I'm writing
this:

  RewriteCond   %{REMOTE_IDENT}@%{REMOTE_HOST}  ^rse@en2\.engelschall\.com$
  RewriteRule   ^service\.cgi                   service-admin.cgi       [L]

  RewriteRule   ^service\.cgi                   service-user.cgi   [L]

etc. pp.

For more information just read the updated documentation in
http://www.engelschall.com/sw/mod_rewrite/arc/mod_rewrite-SNAP/mod_rewrite.html
There is a wide range of more possible rewriting tricks, because I have
created a lot of %{...} variables. With them you can do a lot of useful and a
lot of silly rewriting stuff...

BTW: v2.2-SNAP has another nice flag for RewriteRule now: skip|S=<n>
     which forces the rewriting engine to skip the next <n> rules if the
     current one matched. With this you can setup pseudo if-then-else clauses
     instead of the above "if match then end" examples. I added this flag to
     make the RewriteCond feature more useful.

Alexei: I don't know if you are currently looking for inclusion of
        mod_rewrite, but if so, please first have a look at the current
        v2.2-SNAP. Now really _ALL ESSENTIAL_ functionality is incorporated
        into mod_rewrite. I now will start to only fix bugs and problems
        which you report while trying to include mod_rewrite into 1.2-dev.
        And if there are no more problems reported by you then I will release
        v2.2 officially and then this v2.2 release should be the one which
        gets finally included into 1.2-dev if the other core members give
        their "+1" for mod_rewrite. So, please take the flag of mod_rewrite
        and bring it to the core distribution....

Greetings,
                                        Ralf S. Engelschall    
                                        rse@engelschall.com
                                        http://www.engelschall.com/~rse

Mime
View raw message