[pmwiki-users] CleanURL

Petko Yotov 5ko at free.fr
Sat Mar 31 18:23:21 CDT 2007


On Sunday 01 April 2007 00:24, DaveG wrote:
> On this page http://pmwiki.com/wiki/Cookbook/CleanUrls, the pattern
> ([^/a-z].*) is used throughout. Can someone describe what this is doing?
>
> The way I read it is to match anything not containing a forward-slash or
> letters a-z. 

[^characters] means NOT these characters, so the pattern means:
* The first character is neither / nor a letter between lowercase a-z
* Then, 0 to any number of any character.
* In parentheses means it will be stored as "$1" and sent to pmwiki.php.


> But in the context in which it's used, my interpretation
> makes no sense. Somehow it should translate to match group/pagename, but
>   it's not clear why.

Also "group/pagename?action=X&param1=Y&param2=Z". Here is what I use for root 
level rewrite rules:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f # If it is: neither a file...
RewriteCond %{REQUEST_FILENAME} !-d # nor a directory...
RewriteCond %{REQUEST_FILENAME} !-l # nor a filesystem link...
RewriteRule ^([A-Z0-9\x80-\xFF].*)$ /pmwiki.php?n=$1  [QSA,L]
# then send it to pmwiki -- it will handle it if it can


The ^([A-Z0-9\x80-\xFF].*)$ means :
* start with a capital letter, digit or UTF-8 character
* anything else
* store it in $1 and send to pmwiki.php

^ when in brackets means "negation", when outside of brackets means "start of 
string". $ means end of string.

Have fun,
Petko








More information about the pmwiki-users mailing list