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:
- RewriteEngine on
- RewriteBase /
- # Handle *any* .php files
- RewriteRule ^.*/(.+).php /$1.php [QSA]
- # Ignoe *any* .php files
- RewriteRule !.*.php – [C]
- # Match /Page, add &area=$area to set a default area other than that configured for your YaWiki
- RewriteRule ^([^/]+)$ /index.php?page=$1
- # Ignore all images
- RewriteRule !^.*images.* – [C]
- # Ignore all .php files
- RewriteRule !.*.php – [C]
- # Forward /Area/Page
- RewriteRule ^([^/]+)/(.+) /index.php?page=$2&area=$1
- # Handle all relatively linked images in /Area/Page
- 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