I currently try to translate a .htaccess file which is provided by the chyrp installation routine to lighttpd via the mod_rewrite module.
The source .htaccess file is as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase {$index}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.+$ index.php [L]
</IfModule>
Directory layout (webroot)
/chyrp/
/chyrp/includes/
/chyrp/admin/
/chyrp/feathers/
/chyrp/modules/
/chyrp/themes/
My current attempt
index-file.names = ( "index.php" )
url.access-deny = ( ".twig" )
#taking care of the directory, check if it is one of the known ones, if so go on
#if it is not, redirect to index
url.rewrite-once = (
"^/(|chyrp/)(admin|themes|feathers|modules|includes)(.*)$" => "/chyrp/$2$3",
"^/(|chyrp/).*/$" => "/chyrp/index.php"
)
#check if files exists, if not rewrite to a index.php in the same directory
url.rewrite-if-not-file = (
"^/(|chyrp/)(admin|themes|feathers|modules|includes)(/(index.php)?(.*))?$" => "/chyrp/$2/index.php$5",
"^/(|chyrp/)(.*)" => "/chyrp/index.php"
)
It mostly works, except for the search functionality (testable here: srctwig.com), which does not rewrite correctly (at least that’s my guess) or somewhere the query gets lost.
The search routine itself works properly (demonstration search with 0 results)
A working demo of chyrp can be seen at chyrp demo on apache2
What am I doing wrong?
The reason for the issue was, I was not aware of having to dissect the url in order to extract the
getquery string which I needed to preserve according to a lighttpd mod_rewrite wiki entryDissect:
url.rewrite-once
These directories exist. Do not change anything except for ensuring the proper prefix if not alread there.
Check if a non existant subdir was requested and check for
?, treat everything after that as phpgetquery and append it to the rewrite target.url.rewrite-if-not-file
if the target does not exist just swap out the filename and keep the query (as above)
go to the basefolder if none of the above matches and try to still pass the query
this very last one is just for testing (put
foobarfailure.phpthere to assert it never reaches that line)