我目前正尝试通过.htaccess
模块将chyrp安装例程提供的mod_rewrite
文件翻译为lighttpd。
源.htaccess
文件如下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase {$index}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.+$ index.php [L]
</IfModule>
目录布局(webroot)
/chyrp/
/chyrp/includes/
/chyrp/admin/
/chyrp/feathers/
/chyrp/modules/
/chyrp/themes/
我目前的尝试
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"
)
除了search
功能(在此可测试:srctwig.com)之外,它主要起作用,它不能正确重写(至少是我的猜测)或查询丢失的地方。
搜索例程本身正常工作(demonstration search with 0 results)
可以在chyrp demo on apache2
我做错了什么?
答案 0 :(得分:1)
问题的原因是,我不知道必须剖析网址以便根据lighttpd mod_rewrite wiki entry
提取我需要保留的get
查询字符串
url.rewrite-once = (
"^/(|chyrp/)(admin|themes|feathers|modules|includes)/(.*)$" => "/chyrp/$2/$3",
"^/(|chyrp/).+/(([^\?]+)?(\?.+)?)$" => "/chyrp/index.php$2"
)
url.rewrite-if-not-file = (
"^/(|chyrp/)(admin|themes|feathers|modules|includes)(/([^\?]+)?(\?.+)?)?$" => "/chyrp/$2/index.php$5",
"^/(|chyrp/)(([^\?]+)?(\?.+)?)$" => "/chyrp/index.php$2",
"^/(|chyrp/).*$" => "/chyrp/index.php"
)
解剖:
"^/(|chyrp/)(admin|themes|feathers|modules|includes)/(.*)$" => "/chyrp/$2/$3",
存在这些目录。除非确保正确的前缀(如果没有在那里),否则不要更改任何内容。
"^/(|chyrp/).+/(([^\?]+)?(\?.+)?)$" => "/chyrp/index.php$2"
检查是否请求了一个不存在的子目录,并检查?
,在此之后将所有内容视为php get
查询并将其附加到重写目标。
"^/(|chyrp/)(admin|themes|feathers|modules|includes)(/([^\?]+)?(\?.+)?)?$" => "/chyrp/$2/index.php$5",
如果目标不存在,只需换出文件名并保留查询(如上所述)
"^/(|chyrp/)(([^\?]+)?(\?.+)?)$" => "/chyrp/index.php$2",
如果上述内容都不匹配,请转到base文件夹并尝试仍然传递查询
"^/(|chyrp/).*$" => "/chyrp/index.php"
这最后一个仅用于测试(将foobarfailure.php
放在那里断言它永远不会到达那条线)