I added the following to my theme's functions.php:
function gallery_filter($rules) {
$newrules['gallery/folder/(.*)'] = 'gallery/sp_index.php?dir=./$1';
$newrules['gallery/file/(.*)'] = 'gallery/sp_index.php?file=./$1';
$newrules['gallery/thumb/(.*)'] = 'gallery/sp_getthumb.php?source=./$1';
$rules = array_merge($newrules,$rules);
return $rules;
}
add_filter('rewrite_rules_array', 'gallery_filter');
but it only works if I set $use_verbose_rules = true; in classes.php
Otherwise the reltive links under gallery/ all cause the default front page of wordpress to load.
It works, but I don't think this is how things are supposed to work.
Many thanks to filisofo on other forums for pushing me in the right direction to get as far as I have.