2011-04-17

MoinMoin wiki engine and "clean URLs"

What URLs look smarter? Just look:
http://example.com/index.cgi/ExamplePage
or
http://example.com/ExamplePage


I think, that the second URL looks smarter. Such URLs are called as "clean URLs". But how to achieve this at Your web-site, if You are using MoinMoin wiki engine as website revision system (WRS or CMS)?




Suggest the next situation. You set up MoinMoin wiki engine's moinmoin.cgi as DOCUMENT_ROOT/index.cgi to process requests like http://example.com/. But when ones is browsing Your site, he or she found themselves at address like http://example.com/index.cgi/ExamplePage. It's out of Your wishes. What to do?


Most modern Internet hosting providers give You an option to use rewrite rules to make URL "clean". Just place at the DOCUMENT_ROOT the file .htaccess with the following lines:
Options +FollowSymLinks +ExecCGI
 
RewriteEngine On
 
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /index.cgi/$1 [QSA,L]
I take this example from WebFaction Forum: http://forum.webfaction.com/viewtopic.php?pid=6098#p6098


Now ones can access the ExamplePage at Your site, typing http://example.com/ExamplePage at address line.


But this is just a half of job. Links at pages, generated by MoinMoin, are still "not clean". To fix this fault, open index.cgi, look for a Config class definition (near the end of file) and set properties attribute:
properties = {'script_name': '/'}
I take this example from WebFaction Forum: http://forum.webfaction.com/viewtopic.php?pid=6726#p6726


That's all! :)

No comments:

Post a Comment