Forum

How does UrlToolkit work?

Ahmad
14 July 2010, 22:15
Hiawatha version: 7.3
Operating System: sidux-2010-01 (it's debianlike)

Hello *,

thank you Hugo for kindly answering to my mail. Here are my questions:

Up to now it's not very clear to me, how UrlToolkit works, although I'm not unfamiliar with regexp, though I'm not a real expert to it.
My question is:

Does UrlToolkit work like a subprogramm, i.e. you have an entry point, say the top of it, and then every line of code follows the other
until there is a Return or Exit statement or the last statement at end?

I have the difficulty, that my UrlToolkit-Statements don't work, if I make a call in a browser to:
http://der-spurlose-pfad.doesntexist.org/
the StartFile being in a subdirectory /cgi-bin.

If I call http://der-spurlose-pfad.doesntexist.org/x instead, x being any character(s), all will work perfectly. A hostname:
der-spurlose-pfad.doesntexist.org/cgi-bin would find the StartFile, but woun't work in finding grafics in subdirectories at the same level as /cgi-bin. Similarly I had no success in reordering the statements in UrlToolkit, arranging RequestUri at the end of UrlToolkit.

My UrlToolkit is:
UrlToolkit {
ToolkitID = spurlos
RequestURI exists Return
Match ^/cgi-bin$ Return
Match ^/cgi-bin/index.py?p=$1 Return
...
Match ^/Meister_Crohn/mc.pdf Return
Match ^/(.*)$ Rewrite /cgi-bin/
}

and my VirtualHost is
VirtualHost {
Hostname = der-spurlose-pfad.doesntexist.org
WebsiteRoot = /srv/HP/HP-Der-Spurlose-Pfad
UseToolkit = spurlos
StartFile = index.py
ExecuteCGI = yes
ShowIndex = no
AccessLogfile = /var/log/hiawatha/spurlos-access.log
ErrorLogfile = /var/log/hiawatha/spurlos-error.log
}

As I understand, ^/(.*)$ works even, when there is nothing (no characters) behind the first slash after the URL.
Certainly I made an error, but what error?

Greetings to all,

Ahmad
Hugo Leisink
14 July 2010, 23:32
You could indeed see the UrlToolkit as a sort of program, a script more. It starts at the first line and works its way down. Read the URL TOOLKIT section in the manual page to see what all the commands do.

About your toolkit, I don't fully understand what you want, but my guess is this:
UrlToolkit {
ToolkitID = spurlos
RequestURI isfile Return
Match ^/(.*)$ Rewrite /cgi-bin/index.py?p=$1
}
Ahmad
18 July 2010, 13:10
Hello Hugo,

in the meantime I tried much, but still strange things happen.

First, the good news: During the first invoking of "http://der-spurlose-pfad.doesntexist.org" it will find the StartFile "index.py" in folder
"/cgi-bin", using your proposed UrlToolkit above! And, the desired webpage is displayed, but still
"http://der-spurlose-pfad.doesntexist.org/" (now with a / at the end) is to be seen in the bowser's URL row, and not
"http://der-spurlose-pfad.doesntexist.org/cgi-bin/index.py" as I think should be expected.

And even worse, when I point with the mouse to a button which should display the next web-page by going to
"http://der-spurlose-pfad.doesntexist.org/cgi-bin/index.py?p=01", i.e. the same StartFile in the same folder, but now with a parameter,
it has forgotten about the folder "/cgi-bin" displaying "http://der-spurlose-pfad.doesntexist.org/index.py?p=01"
in the browser's URL row.

This happens in both web-pages I tried. Do I have to alter somehow my programs which worked for years with apache2 and thttpd?
Any ideas to try?
Hugo Leisink
18 July 2010, 23:53
First, note that URL rewriting via the UrlToolkit is an internal Hiawatha thing. You won't see anything changing in the browser's URL bar.

What happens is that your scripts links to /index.py, which does not exist. The UrlToolkit then redirects to /cgi-bin/index.php?p=index.py. It's your script that contains the error, not the UrlToolkit rule.

Looking at your URLs, I think you don't need the UrlToolkit at all. Just use a index.html in the root which redirects to /cgi/index.py via a HTML meta tag and you're done.
Ahmad
19 July 2010, 07:55
Thank you!
This topic has been closed.