[plt-scheme] url rewriting
I've got url rewriting working for the web server. It works like a breeze.
I've added the url rewriter to the web-server-unit.ss file; added the
url-rewriter.scm to the dispatchers directory.
Please have a look at some documentation at:
http://www.elemental-programming.org/urlrewriting.html
I'm attaching the rewriter code, the configuration (scheme) file and
a log of the url rewriting.
This code needs to be further integrated with the web-server code, because
it's not integrated in the configuration-table file.
--Hans
www at memait:~/web-root$ plt-web-server-text -f configuration-table -p 8000
rules:(("^mail.homeopathie[-]nederland.nl$" "^[/]([^.]+[.]html)$")
("^mail.homeopathie[-]nederland.nl$" "^[/]$")
("^mail.homeopathie[-]nederland.nl$" "^[/](.*)$")
("localhost|homeopathie[-]nederland.nl" "^[/]([^.]+[.]html)$")
("localhost|homeopathie[-]nederland.nl" "^[/]$"))
url-rewriting url:/, host:homeopathie-nederland.nl
url-rewriting: matching host homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: #f
url-rewriting: matching host homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: #f
url-rewriting: matching host homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: #f
url-rewriting: matching host homeopathie-nederland.nl with
localhost|homeopathie[-]nederland.nl. match: (homeopathie-nederland.nl)
url-rewriting: matching url / with ^[/]([^.]+[.]html)$. match: #f
url-rewriting: matching host homeopathie-nederland.nl with
localhost|homeopathie[-]nederland.nl. match: (homeopathie-nederland.nl)
url-rewriting: matching url / with ^[/]$. match: (/)
url-rewriting: result: /servlets/hwiki.scm/index.html
rules:(("^mail.homeopathie[-]nederland.nl$" "^[/]([^.]+[.]html)$")
("^mail.homeopathie[-]nederland.nl$" "^[/]$")
("^mail.homeopathie[-]nederland.nl$" "^[/](.*)$")
("localhost|homeopathie[-]nederland.nl" "^[/]([^.]+[.]html)$")
("localhost|homeopathie[-]nederland.nl" "^[/]$"))
url-rewriting url:/, host:mail.homeopathie-nederland.nl
url-rewriting: matching host mail.homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: (mail.homeopathie-nederland.nl)
url-rewriting: matching url / with ^[/]([^.]+[.]html)$. match: #f
url-rewriting: matching host mail.homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: (mail.homeopathie-nederland.nl)
url-rewriting: matching url / with ^[/]$. match: (/)
url-rewriting: result: /servlets/hwiki.scm/index.html?context=test
rules:(("^mail.homeopathie[-]nederland.nl$" "^[/]([^.]+[.]html)$")
("^mail.homeopathie[-]nederland.nl$" "^[/]$")
("^mail.homeopathie[-]nederland.nl$" "^[/](.*)$")
("localhost|homeopathie[-]nederland.nl" "^[/]([^.]+[.]html)$")
("localhost|homeopathie[-]nederland.nl" "^[/]$"))
url-rewriting url:/zk.html, host:mail.homeopathie-nederland.nl
url-rewriting: matching host mail.homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: (mail.homeopathie-nederland.nl)
url-rewriting: matching url /zk.html with ^[/]([^.]+[.]html)$. match:
(/zk.html zk.html)
url-rewriting: result: /servlets/hwiki.scm/zk.html?context=test
rules:(("^mail.homeopathie[-]nederland.nl$" "^[/]([^.]+[.]html)$")
("^mail.homeopathie[-]nederland.nl$" "^[/]$")
("^mail.homeopathie[-]nederland.nl$" "^[/](.*)$")
("localhost|homeopathie[-]nederland.nl" "^[/]([^.]+[.]html)$")
("localhost|homeopathie[-]nederland.nl" "^[/]$"))
url-rewriting url:/test.gif, host:mail.homeopathie-nederland.nl
url-rewriting: matching host mail.homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: (mail.homeopathie-nederland.nl)
url-rewriting: matching url /test.gif with ^[/]([^.]+[.]html)$. match: #f
url-rewriting: matching host mail.homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: (mail.homeopathie-nederland.nl)
url-rewriting: matching url /test.gif with ^[/]$. match: #f
url-rewriting: matching host mail.homeopathie-nederland.nl with
^mail.homeopathie[-]nederland.nl$. match: (mail.homeopathie-nederland.nl)
url-rewriting: matching url /test.gif with ^[/](.*)$. match: (/test.gif
test.gif)
url-rewriting: result: /test/test.gif
Jay McCarthy schreef:
> The run.ss file is intended to be copied and modified, like the
> configuration-table. The web-server-unit.ss file contains the default
> sequence, so if you want that, then modify run.ss to have that
> sequence + your changes.
>
> Jay
>
> On 6/21/07, Hans Oesterholt-Dijkema <hdnews at gawab.com> wrote:
>> I didn't look into run.ss, but I looked into web-server-unit.ss.
>> I saw the default dispatcher sequence.
>>
>> Do I understand you right, that I need to alter the code in these
>> files to include the url rewriting system?
>>
>> --Hans
>>
>>
>>
>> Op 20/6/2007 schreef "Jay McCarthy" <jay.mccarthy at gmail.com>:
>>
>> >Check out web-server/run.ss and web-server/web-server-unit.ss. The
>> >first contains an example of the sort of start-up script you will want
>> >to write and the second contains the current code for setting up the
>> >default dispatcher sequence.
>> >
>> >Jay
>> >
>> >On 6/20/07, Hans Oesterholt-Dijkema <hdnews at gawab.com> wrote:
>> >> So, how can I install a new dispatcher?
>> >>
>> >> --Hans
>> >>
>> >>
>> >> Jay McCarthy schreef:
>> >> > Yes, it is possible.
>> >> >
>> >> > Implement a custom dispatcher [1] that does the rewriting, then use
>> >> > your own dispatching sequencing and put the rewriting dispatcher at
>> >> > the start. Everything "will just work". Send me the code and I can
>> >> > then integrate it. Basically you want:
>> >> >
>> >> > ; make : (url? -> url?) (conn? req? -> void) -> (conn? req? ->
>> void)
>> >> > (define (make url->url inner)
>> >> > (lambda (conn req)
>> >> > (inner conn (update-request-url req (url->url (request-url
>> req))))))
>> >> >
>> >> > Jay
>> >> >
>> >> > 1. See new documentation, in SVN after `mzscheme -mvt
>> >> > docs/doc-installer.ss' or online at:
>> >> >
>> >> >
>> http://jay.teammccarthy.org/tmp/web-server-reference/dispatchers.html#(part%20dispatchers)
>>
>> >> >
>> >> >
>> >> > On 6/7/07, Hans Oesterholt-Dijkema <hdnews at gawab.com> wrote:
>> >> >> L.S.,
>> >> >>
>> >> >> Is it possible to implement url rewriting with the PLT Webserver?
>> >> >> I'd like to rewrite things like:
>> >> >>
>> >> >> http://x.y.z/somepage.html
>> >> >>
>> >> >> to
>> >> >>
>> >> >> http://x.y.z/servlets/program?page=somepage
>> >> >>
>> >> >> Preferably without seeing it at the outside; except when the
>> servlet
>> >> >> really becomes "active",
>> >> >> i.e. is used in a continuation style fashion to handle forms.
>> >> >>
>> >> >> --Hans
>> >> >>
>> >> >> _________________________________________________
>> >> >> For list-related administrative tasks:
>> >> >> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>> >--
>> >Jay McCarthy <jay.mccarthy at gmail.com>
>> >http://jay.teammccarthy.org
>> >
>> >
>>
>
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: url-rewriting.scm
URL: <http://lists.racket-lang.org/users/archive/attachments/20070621/ccebdf61/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rewrite-rules.scm
URL: <http://lists.racket-lang.org/users/archive/attachments/20070621/ccebdf61/attachment-0001.ksh>