Button Button
Nicer URLs (000002)

You can get rid of the "sputnik.cgi" in your URLs.

If you follow the instructions for installing Sputnik to work with CGI, your Sputnik will have a URL that includes "sputnik.cgi?" in it. It's a little ugly, but the good news is that you can get rid of it. Suppose your Sputnik is currently running as "http://www.example.com/cgi-bin/sputnik.cgi". You can make it be http://www.example.com/wiki/, where a page named "Some_Page" would be located at "http://www.example.com/wiki/Some_Page". Much better looking.

How you do this depends on what web server you are using. Here are the instructions for Apache.

This change requires two steps. First, we'll need to tell Apache that a request for "/wiki/" should be interpreted as a request for "/cgi-bin/sputnik.cgi" and a request for "/wiki/Some_Page" should be interpreted as request for "/cgi-bin/sputnik.cgi?p=Some_Page". We do this by editing (or creating) a file called called ".htaccess" in the root of Apache's document directory, putting the following lines into it:

RewriteEngine On
RewriteBase /
RewriteRule ^wiki/$ /cgi-bin/sputnik.cgi [L]
RewriteCond  %{QUERY_STRING} ^(.*)$ 
RewriteRule ^wiki/(.*)$ /cgi-bin/sputnik.cgi?p=$1&%1 [L]

Here, the first line turns on the rewrite engine, the second established the path relative to which the consequent rules works, and the last three lines set up two rewrite rules. The first of the two, on line 3, catches the case when node name is not specified. The second rule, on lines 4 and 5, catches the case where node name is specified, in which case it is inserted into the query string and the rest of the query string is then appended after an ampersand. (The query string is captures on line 4.)

Make sure that your .htaccess is readable by Apache.

Then test it. When you go to http://www.example.com/wiki/ you should see your home page and when you go to http://www.example.com/wiki/Some_Page you should see "Some Page".

If this worked, go to the next step: edit "sputnik/config" and set BASE_URL to "/wiki/" in the sputnik/config node and USENICEURLS to true:

NICE_URL = "/wiki/"
USE_NICE_URLS = true

This will make sure that Sputnik not only responds to the /wiki/ requests but also points all links to /wiki/ rather than to "/cgi-bin/sputnik.cgi".

On Lighttpd simply add the following lines to your server configuration:

server.modules += ( "mod_rewrite" )
url.rewrite-once = ( "^/wiki/(?!cgi\-bin|sputnik\.cgi)(.*)$" => "/wiki/cgi-bin/sputnik.cgi?p=$1" )

Using Rewrite Rules with Apache+Xavante

You can also get rid of the "sputnik.ws" in your URLs when running on Xavante behind Apache.

Here are the Apache rewrite rules to mount a Sputnik instance on the wiki/ directory:

RewriteEngine On
RewriteBase /
RewriteRule ^wiki/$ http://127.0.0.1:8080/sputnik.ws [P]
RewriteCond  %{QUERY_STRING} ^(.*)$ [L]
RewriteRule ^wiki/(.*)$ http://127.0.0.1:8080/sputnik.ws?p=$1&%1 [P]