Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Installation for Hiawatha web-server


Reply


2 Posts   2204 Views

Avatar
phild

Community Member, 2 Posts

5 November 2008 at 10:02pm

I want to get silverstripe going with the Hiawatha web-server that does support url re-writing via its URL Toolkit feature:

5.3 URL toolkit
The most important feature of the URL toolkit is URL rewriting. The easiest way to explain URL rewriting, is to start with an example.

UrlToolkit {
ToolkitID = images
Match ^/pics/ Return
Match (.*)\.jpeg$ Rewrite $1.jpg
}

UrlToolkit {
ToolkitID = example
Call images
Match a Rewrite b 3
Match /index.php3(.*) Rewrite /index.php$1
}

VirtualHost {
Hostname = www.domain.com
...
UseToolkit = example
}

In this example, the configuration for the virtual host www.domain.com uses the URL rewrite rule 'example'. After the declaration of the id, the rule 'images' is called. The rule 'images' returns when the URL starts with "/pics/". If this is not the case, ".jpeg" at the end of the URL will be replaced with ".jpg". The rule 'example' continues with replacing "a" with "b" in the URL. This is done for maximum 3 times. For example, "/aaaaa.html" will be rewritten to "/bbbaa.html". The rule ends with replacing "/index.php3" with "/index.php". The text after "/index.php3" is copied to the new URL. For example "/index.php3?page=start" will be rewritten to "/index.php?page=start".

The complete syntax of the URL toolkit in Hiawatha is:

UrlToolkit {
Call <toolkit_id>
Match <url> Call <toolkit_id>
Match <url> DenyAccess
Match <url> Exit
Match <url> FastCGI <fcgi_id>
Match <url> Goto <toolkit_id>
Match <url> Redirect <url>
Match <url> Return
Match <url> Rewrite <replace> [<max_loop>] [Continue|Return]
Match <url> Skip <number>
RequestURI exists|isfile|isdir Return|Exit
ToolkitID = <toolkit_id>
Skip <number>
}

Explanation of the commands:

* 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.
* FastCGI: use FastCGI server with id <fcgi_id> and terminate toolkit processing.
* Goto: execute another rule and stop afterwards.
* Match: perform the following action if <url> matches the requested URL.
* 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.
* ToolkitID: assign a label to the current rule set.
* Return: return from the current rewrite rule.
* Skip: skip the following <number> of lines (ToolkitID excluded).

After a rewrite, always be sure your new URL starts with a slash (/). If it doesn't, Hiawatha will consider it an invalid URL. Test your URL rewriting rules with the tool 'wigwam'. See the wigwam manualpage for information about its usage.

appreciate any pointers for how to write the config for hiawatha...

Thanks

Phil

Avatar
phild

Community Member, 2 Posts

12 November 2008 at 11:33am

Edited: 12/11/2008 11:34am

Replying to myself in case anyone else wants to use this brilliant web-server.

I got some help from the author Hugo Leisink see this link to the discussion on the
[url=http://www.hiawatha-webserver.org/forum/topic/127]Hiawatha forum[/url]:

The guts are you need to have a re-write rule called a URLToolkit in Hiawatha that looks like:

UrlToolkit {
ToolkitID = silverstripe
RequestURI isfile Return
Match (.*)\?(.*) Rewrite $1&$2 Continue
Match ^/(.*) Rewrite /sapphire/main.php?url=$1
}

VirtualHost {
Hostname = silverstripe-hostname
WebsiteRoot = /path/to/silverstripe
ExecuteCGI = yes
UseToolkit = silverstripe
TriggerOnCGIstatus = no
}

The virtual host - hostname should resolve to the hostname you enter for "silverstripe-hostname". Also, you should not have two VirtualHost sections that point to the same hostname - only the first section is processed.

Note that the UrlToolkit changed its name and these instructions apply to Hiawatha 6.10 onwards