Playing with pattern matching

One of the spiffy new features in Web Server 7 is the pattern matching capabilities (see elving's blog for several articles on how this can be used).

I've been playing around with it in an attempt to get phpBB mod_rewrite mods to work. While the modules seem to really bite (they all seems written from the perspective of trying to get pages into Google rather than simply improving the end user experience with more comprehensible URIs), the pattern matching has really been a joy to work with:

# mode_rewrite syntax
RewriteRule \^post-([0-9]\*).html&highlight=([a-zA-Z0-9]\*) viewtopic.php?p=$1&highlight=$2 [L,NC]
RewriteRule \^post-([0-9]\*).\* viewtopic.php?p=$1 [L,NC]
RewriteRule \^view-poll([0-9]\*)-([0-9]\*)-([a-zA-Z]\*).\* viewtopic.php?t=$1&postdays=$2&postorder=$3&vote=viewresult [L,NC]

# Web Server 7 syntax
 <if $uri=~"\^(/forum)/post-([0-9]\*).html&highlight=([a-zA-Z0-9]\*)$">
    NameTrans fn="restart"
              uri="$1/viewtopic.php?p=$2&highlight=$3"
 </if>
 <elseif $uri=~"\^(/forum)/post-([0-9]\*).\*">
    NameTrans fn="restart"
              uri="$1/viewtopic.php?p=$2"
 </elseif>
 <elseif $uri=~"\^(/forum)/view-poll([0-9]\*)-([0-9]\*)-([a-zA-Z]\*).\*">
    NameTrans fn="restart"
              uri="$1/viewtopic.php?t=$2&postdays=$3&postorder=$4&vote=viewresult"
 </elseif>
 <elseif $uri=~"\^(/forum)/\^about([0-9]\*).html&highlight=([a-zA-Z0-9]\*)">
    NameTrans fn="restart"
              uri="$1/viewtopic.php?t=$2&highlight=$3"
 </elseif>

The Web Server 7 syntax isn't as compact (I also made some minor changes to the reg-ex since my URI space is slightly different from the original author's) but is more comprehensible.

This is darned cool.

Comments:

Many thanks for the posting on how to do URI rewrites and redirects in Sun Web Server 7.

I just finished installing update 1.

In this blog you mention checking out elving's blog.

When I found http://blogs.sun.com/elving/ I see it has not been updated in almost a year -
last enty Oct 2006.

Is there a new blog page for Elving?

Posted by Robert on August 16, 2007 at 04:35 AM PDT #

Unfortunately Elving is probably not going to be very active blogging about Web Server any longer.

If you look at newer entries in my blog you'll see more information about my experiences with doing rewriting of URI space, etc.

Posted by DzM on September 10, 2007 at 09:11 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

jmccabe

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today