YaWiki + Nice Urls = Yay!

On IRC today, someone wanted their YaWiki? to have nicer urls, like: http://crtx.org/CrtxDB

I had been wanting this forever, so I went ahead and wrote the simple rules needed. Unfortunately, then the person pointed out that they had more than one area on their Wiki. So I went ahead and whipped this up:

  1. RewriteEngine on
  2. RewriteBase /
  3. # Handle *any* .php files
  4. RewriteRule ^.*/(.+).php /$1.php [QSA]
  5. # Ignoe *any* .php files
  6. RewriteRule !.*.php – [C]
  7. # Match /Page, add &area=$area to set a default area other than that configured for your YaWiki
  8. RewriteRule ^([^/]+)$ /index.php?page=$1
  9. # Ignore all images
  10. RewriteRule !^.*images.* – [C]
  11. # Ignore all .php files
  12. RewriteRule !.*.php – [C]
  13. # Forward /Area/Page
  14. RewriteRule ^([^/]+)/(.+) /index.php?page=$2&area=$1
  15. # Handle all relatively linked images in /Area/Page
  16. RewriteRule ^(.+)/images/(.+) /images/$2

As an example: http://crtx.org/CrtxDB and http://crtx.org/Main/CrtxTemplate

Update: Changed the rules to ignore all .php files, it broke things otherwise (like say, editing :-)

– Davey

Warning: file_get_contents(index.php): failed to open stream: No such file or directory in /nfs/c03/h02/mnt/170398/domains/daveyshafik.com/html/wp-includes/plugin.php on line 441