Page 1 of 1

Hiawatha gurus, I need your help with URLToolkit

Posted: Sat 11 Aug 2018, 01:42
by jafadmin
I have a simple, LAN only, HTML, hiawatha site running on a puppy in /root/Web-Server with a "index.html" file.

I'm trying to make URLTool fix URL's that don't match the site. (goofy clicks in favorites, etc.) My hiawatha.conf file:

Code: Select all

ServerId = webuser
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log

UrlToolkit {
	ToolkitID = my_rewrite
	RequestURI exists Return
	Match .* Rewrite /index.html
}

Binding {
	Port = 80
	Interface = 172.28.226.1
}

Hostname = 127.0.0.1
WebsiteRoot = /root/Web-Server
StartFile = index.html
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log

VirtualHost {
  Hostname = localhost
  WebsiteRoot = /root/Web-Server
  StartFile = index.html
  AccessLogfile = /var/log/hiawatha/access.log
  ErrorLogfile = /var/log/hiawatha/error.log
  UseToolkit = my_rewrite
}
#add this stuff to get a perl script working (pplog)...
#QUISP has a binary executable CGI named 'quisp.bin'...
MimetypeConfig = /etc/mime.types
#CGIhandler = /usr/bin/perl:pl
CGIextension = pl,bin
ExecuteCGI = yes
#QUISP puts %0D, %0A (carriage-return, line-feed) chars in the url
#(v128), to allow chars below ascii 32 need this...
SecureURL = no
This is on Precise 5.71 .. Anyway, the "UseToolkit = my_rewrite" isn't changing the urls to the index.html ..

Any insights would be greatly appreciated. :(

Posted: Sat 11 Aug 2018, 17:42
by rockedge
what version of Hiawatha are you running? I assume its around version 6.17.1.

have you tried using wigwam with the -t switch? this tests URL's you can input and see what the rewrite of the tookkit will look like.

Code: Select all

wigwam -t my_rewrite
manual -> https://www.hiawatha-webserver.org/manpages/wigwam

tests with your hiawatha.conf are below

Posted: Sat 11 Aug 2018, 18:23
by jafadmin
It gives me the following. The problem is that if I type a url in the browser window, it works fine, but if I select a saved link from favorites, it hangs and doesn't serve the content properly.

I = Stumped.

Probably has to do with that "Bad URL" message, right?

Posted: Sat 11 Aug 2018, 20:19
by trapster
try:

Match /(.*) Rewrite /index.html

?

Posted: Sat 11 Aug 2018, 21:33
by jafadmin
trapster wrote:try:

Match /(.*) Rewrite /index.html

?
No Joy .. Actually made it worse ..

Posted: Sun 12 Aug 2018, 00:40
by jafadmin
Ok, I think it messes up when the url has "https" instead of "http"

Any ideas how to fix that?

thx

Posted: Sun 12 Aug 2018, 01:13
by trapster
From the Hiawatha web sight
UseSSL is for https
?


The complete syntax of the URL toolkit in Hiawatha is:


UrlToolkit {
ToolkitID = <toolkit_id>

Call <rewrite_id>
Header <key> [!]<value> Call|DenyAccess|Exit|Goto|Return|Skip|Use
Match [!]<url> Ban|Call|DenyAccess|Exit|Expire|Goto|Return|Rewrite|Redirect|Skip|UseFastCGI
Method [!]<request method> Call|DenyAccess|Exit|Goto|Redirect|Return|Skip|Use
RequestURI exists|isfile|isdir Return|Exit
Skip <lines>
UseSSL Call|Exit|Goto|Return|Skip
}


The format of the actions is as follows:

Ban <seconds>
Call <toolkit_id>
DenyAccess
Exit
Expire <number> (seconds|minutes|hours|days|weeks|months) [Public|Private] [Return|Exit]
Goto <toolkit_id>
Redirect <url>
Return
Rewrite <replace> [<max_loop>] [Continue|Return]
Skip <lines>
Use <url>
UseFastCGI <fastcgi_server_id>

Explanation of the commands:

Ban: Ban the client for <seconds> seconds.
Call: Execute another rule and proceed with the current rule afterwards.
DenyAccess: Denies access to the requested file (results in a 403 error) and terminate toolkit processing.
Exit: Stop URL rewriting.
Expire: Adds an Expires HTTP header with current timestamp + <time>. The default behaviour is to continue after an Expire action.
Goto: Execute another rule and terminate toolkit processing.
Match: Perform the following action if <url> matches the requested URL.
Method: Perform an action for a certain request method.
Redirect: Redirect the browser to <url> via a 301 and terminate toolkit processing.
RequestURI: Check if the requested URL is a file or a directory.
Rewrite: Rewrite the current URL for maximum <max_loop> times (default=1) and terminate toolkit processing.
Return: Return from the current rewrite rule.
Skip: Skip the following <number> of lines (ToolkitID excluded).
ToolkitID: Assign a label to the current rule set.
Use: Replace the current URL with a new one.
UseFastCGI: Use FastCGI server with id <fastcgi_server_id> and terminate toolkit processing.
UseSSL: Perform action when client is connected via HTTPS.