There are three rewriting options available:

If you set REWRITE_MODE = 0, read no further - the wiki will work fine like this.

However, if you set it to 1 or 2, you will need to define Rewrite Rules, as below. This is based on the Apache web server, so if you use a different one, please see its documentation to see if you need to alter anything suggested here.

These instructions may appear in the server's configuration, or as an .htaccess files in the appropriate directory. In the examples below, it is assumed that the instructions appear in the .htaccess file in the directory where the wiki's HTML files live - i.e. the one which the web user is accessing.

The examples below also assume that the URI of the Monkey Wiki script is '/cgi-bin/monkeywiki.py'.

The first RewriteRule in each example deals with the case where the user has requested just the base URL of the wiki - i.e. not specified a file. You can omit this rule if you have dealt with this in another way. For example you may have renamed your Monkey Wiki script 'index.cgi' and placed it appropriately.

REWRITE_MODE = 1

All we need to do is to take the name of the page that is wanted from the http request, where it will appear with a '.html' extension, and call the Monkey Wiki script with this page name as an argument called 'page'. If other arguments have already been specified in the form of a query string, that query string is retained, and our page argument is tacked onto it by the use of the 'QSA' flag.

  RewriteEngine on

  RewriteRule  ^/?$  /cgi-bin/monkeywiki.py
  RewriteRule  ^(.+)\.html$  /cgi-bin/monkeywiki.py?page=$1  [QSA]

REWRITE_MODE = 2

It gets a little bit more complicated here!

All the Monkey Wiki script does in terms of managing HTML files is to save any page which is subject to a simple request to view it, and deletes any HTML version of a page if anything in the underlying wikipage changes. A new HTML version is only created when the next user makes a simple request to view that page.

So the script should be only be called if no HTML version of the file exists or the request is not straightforward - e.g. the user wants to edit the page.

  RewriteEngine on

  RewriteRule  ^/?$  /cgi-bin/monkeywiki.py

  RewriteCond  %{QUERY_STRING}  ^action= [OR]
  RewriteCond  %{REQUEST_FILENAME}  !-f
  RewriteRule  ^(.+)\.html$  /cgi-bin/monkeywiki.py?page=$1  [QSA]

It is a good idea (though not essential) also to give some consideration to how these static HTML pages will be cached in the user's browser. It would be annoying for someone to make an edit and then two minutes later try to access that page, only to find it is still showing the old version because their browser has cached it. Of course using Refresh on the browser would cure the problem, but it might not be obvious what is going on. A further entry in the the .htaccess file can sort this out. There are various ways of achieving the same effect but here is what I have used (it just sets the expiry of the file to the same time it was modified/created - i.e. it has a cachable lifespan of nil):

  ExpiresActive on
  ExpiresByType text/html "modified"

Last modified: Fri May 9 11:06:53 2008

Valid XHTML 1.0 Strict Valid CSS! [Python Powered] hosting by gradwell dot com Ltd
Wiki Spam controlled by LinkSleeve