examples/rewrite-rules.scm
(module rewrite-rules mzscheme
	(require (lib "pregexp.ss"))
        (provide rewrite-rules
                 rewrite-rules-debug)

	(define re-context (pregexp "[?]context[=][^&]"))

	(define re-host    "(it4humans|memait|localhost|homeopathie-nederland)")

	(define (get-host match)
	  (let ((h (cadr match)))
	    (if (string-ci=? h "memait")
	      "it4humans"
	      h)))

        (define (rewrite-rules)
          (list
           ;;; Standard rewriting, i.e.
           ;;; 1. regular expression or #t for host
           ;;; 2. regular expression or #t for url
           ;;; rewriter function
           (list re-host
                 "^[/]([^.]+[.]html)$"
                 (lambda (mhost m host url)
                   (format "/servlets/hwiki.scm/~a?context=~a" (cadr m) (get-host mhost))))

           (list re-host
                 "^[/]$"
                 (lambda (mhost m host url)
                   (format "/servlets/hwiki.scm/index.html?context=~a" (get-host mhost))))

           (list re-host
                 "^[/]servlets[/;].*$"
                 (lambda (mhost m host url)
		   (if (not (pregexp-match re-context url))
                      (format "~a?context=~a" url (get-host mhost))
		      url)))

           (list #t
                 "^[/]tinymce[/;].*$"
                 (lambda (mhost m host url)
                   url))

           (list re-host
                 "^[/].*$"
                 (lambda (mhost m host url)
                   (format "/~a~a" (get-host mhost) (car m))))
           
           ;;; Matcher function (example)
           ;;; Rewriter function
           (list 
            (lambda (host url)
              (if (string-ci=? host "www.memait.nl")
                  (values (list host) (list url))
                  #f))
            (lambda (mhost murl host url)
              (format "~a?context=~a" url "memait")))
              
            
           ))

        (define (rewrite-rules-debug)
          #t)


        )