Project

General

Profile

HowToRewriteForPMWiki » History » Revision 8

Revision 7 (Anonymous, 2007-10-09 21:14) → Revision 8/13 (Anonymous, 2008-10-03 15:18)

== PMWiki CleanURLs with Lighttpd == 

 Rewriting for PMWiki isn't very difficult at all. 

 === Dedicated vhost === 

 First of all, I'm assuming you have a hostname setup specifically for your wiki. A vhost of wiki.example.com wiki.domain.tld is used what I'll use in this example. Add  

 Your pmwiki needs to be setup in the root of this host. This makes life much easier. Now, simply add this snippet to your lighttpd.conf, after enabling mod_rewrite.  

 {{{ 
 $HTTP["host"] == "wiki.example.com" "wiki.domain.tld" {    
   index-file.names = ("pmwiki.php") 
   url.rewrite-once = ( 
     "^/([a-zA-Z0-9]+)/([a-zA-Z=?0-9.&:\-_%]+)$" => "/pmwiki.php?n=$1.$2", 
     "^/([a-zA-Z0-9/]+)$" "/pmwiki.php?n=$1.$2","^/([a-zA-Z0-9/]+)$" => "/pmwiki.php?n=Category.$1" 
   ) 
 } 
 }}} 

 I have this code setup to redirect any one-level inquiries (http://wiki.example.com/group) (http://wiki.domain.tld/group) to Category.$1. You can change that easily, and make it $1.$1 or Main.$1, whatever you want. (''blaster8'': I have found that to make all of the links with the 'lean' skin sane, the option $1.!HomePage is the best replacement for Category.$1) 


 Now, change your config variables in config.php to the following: 


 {{{ 
 $EnablePathInfo = 1; 
 $ScriptUrl = "http://wiki.example.com"; "http://wiki.domain.tld"; 
 $PubDirUrl = "http://wiki.example.com/pub"; "http://wiki.domain.tld/pub"; 
 }}} 


 === Subdirectory === 

 To set up a wiki in `http://example.com/wiki/` instead of `http://wiki.example.com/`, perform the following steps: Congratulations, it's setup and working. 

 Put the following in PMWiki's `config.php`: 
 {{{ 
 $EnablePathInfo = 1; 
 $ScriptUrl = "http://example.com/wiki"; 
 $PubDirUrl = "http://example.com/wiki/pub"; 
 }}} 

 Put this in Lighttpd's `lighttpd.conf`: 
 {{{ 
 url.rewrite-once = ( 
     "^/wiki/([a-zA-Z0-9]+)/([a-zA-Z=?0-9.&:\-_%]+)$" => "/wiki/pmwiki.php?n=$1.$2", 
     "^/wiki/([a-zA-Z0-9/]+)$" => "/wiki/pmwiki.php?n=Category.$1" 
 ) 
 }}} 

 Create a file called `index.php` with the following contents in the same directory as `pmwiki.php`: 

 {{{ 
 <?php require("pmwiki.php"); ?> 
 }}}