Hi,
I'm running the weblog software Serendipity (S9Y) on a Hiawatha webserver and I have some strange behaviour with my URL rewrite rules.
S9Y itself generates some rewrite rules for Apache depending on its configuration and I've tried to adapt those rules to the URL toolkit syntax.
Here is the generated .htaccess for Apache's mod_rewrite:
RewriteEngine On
RewriteBase /
RewriteRule ^serendipity_admin.php serendipity_admin.php [NC,L,QSA]
RewriteRule ^((archives/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]
RewriteRule ^(authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [NC,L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) index.php?url=delete/$1/$2/$3 [L,QSA]
RewriteRule ^(admin|entries)(/.+)? index.php?url=admin/ [L,QSA]
RewriteRule ^archive/? index.php?url=/archive [L,QSA]
RewriteRule ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) rss.php?file=$1&ext=$2
RewriteRule ^(plugin|plugin)/(.*) index.php?url=$1/$2 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^comments/(.*) index.php?url=/comments/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css)$ index.php?url=/$1 [L,QSA]
RewriteRule ^index\.(html?|php.+) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
#RewriteCond %{REQUEST_URI} !-U
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]
<Files *.tpl.php>
deny from all
</Files>
<Files *.tpl>
deny from all
</Files>
<Files *.sql>
deny from all
</Files>
<Files *.inc.php>
deny from all
</Files>
<Files *.db>
deny from all
</Files>
And here is what I've come up with for URL toolkit:
UrlToolkit {
ToolkitID = s9y
Match ^/serendipity_admin.php Rewrite /serendipity_admin.php
Match ^/((archives/([0-9]+)-[0-9A-Za-z\.\_!;,\+\-\%]+\.html)/?) Rewrite /index.php?/$1
Match ^/(authors/([0-9]+)-[0-9A-Za-z\.\_!;,\+\-\%]+) Rewrite /index.php?/$1
Match ^/(feeds/categories/([0-9;]+)-[0-9A-Za-z\.\_!;,\+\-\%]+\.rss) Rewrite /index.php?/$1
Match ^/(feeds/authors/([0-9]+)-[0-9A-Za-z\.\_!;,\+\-\%]+\.rss) Rewrite/index.php?/$1
Match ^/(categories/([0-9;]+)-[0-9A-Za-z\.\_!;,\+\-\%]+) Rewrite /index.php?/$1
Match ^/archives([/A-Za-z0-9]+)\.html Rewrite /index.php?url=/archives/$1.html
Match ^/([0-9]+)[_\-][0-9A-Za-z_\-]*\.html Rewrite /index.php?url=$1-article.html
Match ^/feeds/(.*) Rewrite /index.php?url=/feeds/$1
Match ^/unsubscribe/(.*)/([0-9]+) Rewrite /index.php?url=/unsubscribe/$1/$2
Match ^/approve/(.*)/(.*)/([0-9]+) Rewrite /index.php?url=approve/$1/$2/$3
Match ^/delete/(.*)/(.*)/([0-9]+) Rewrite /index.php?url=delete/$1/$2/$3
Match ^/(admin|entries)(/.+)? Rewrite /index.php?url=admin/
Match ^/archive/? Rewrite /index.php?url=/archive
Match ^/(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) Rewrite /rss.php?file=$1&ext=$2
Match ^/(plugin|plugin)/(.*) Rewrite /index.php?url=$1/$2
Match ^/search/(.*) Rewrite /index.php?url=/search/$1
Match ^/comments/(.*) Rewrite /index.php?url=/comments/$1
Match ^/(serendipity\.css|serendipity_admin\.css) Rewrite /index.php?url=/$1
Match ^/index\.(html?|php.+) Rewrite /index.php?url=index.html
Match ^/htmlarea/(.*) Rewrite /htmlarea/$1
Match ^/(.*\.html?) Rewrite /index.php?url=/$1
Match .*.tpl.php DenyAccess
Match .*.tpl DenyAccess
Match .*.sql DenyAccess
Match .*.inc.php DenyAccess
Match .*.db DenyAccess
}
In general this works as expected. A few exceptions are that the search doesn't work, and the archives links only seem to depend on a contained id number and the title of an article is ignored. So I don't get a 404 if the link to an article is incorrect.
And I wasn't quite sure how to translate the QSA flag, so I just ignored it... Don't know if that could be part of the problem.
Hiawatha version: 7.3
Operating System: Debian Stable