1

我目前尝试通过模块将chyrp安装例程.htaccess提供的文件转换为 lighttpd 。mod_rewrite

.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),它没有正确重写(至少这是我的猜测)或查询丢失的地方。搜索例程本身工作正常(演示搜索结果为 0) chyrp 的工作演示可以在 apache2 上的 chyrp 演示中看到

我究竟做错了什么?

4

1 回答 1

1

问题的原因是,我不知道必须剖析 url 才能提取get我需要根据lighttpd mod_rewrite wiki 条目保留的查询字符串

    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"
    )

解剖:

url.rewrite-once

"^/(|chyrp/)(admin|themes|feathers|modules|includes)/(.*)$" => "/chyrp/$2/$3",

这些目录存在。除了确保正确的前缀(如果还没有)之外,不要更改任何内容。

"^/(|chyrp/).+/(([^\?]+)?(\?.+)?)$" => "/chyrp/index.php$2"

检查是否请求了不存在的子目录并检查?,将之后的所有内容视为 phpget查询并将其附加到重写目标。

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"

这最后一个只是用于测试(放在foobarfailure.php那里断言它永远不会到达那条线)

于 2012-08-22T00:04:29.007 回答