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のデモ検索)Apache2のchyrp demoで、chyrpの動作デモを確認できます。

私は何が間違っているのですか?

4

1 に答える 1

1

この問題の理由は、 lighttpd mod_rewrite wiki エントリgetに従って保存する必要があるクエリ文字列を抽出するために、URL を分析する必要があることを認識していなかったためです。

    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"

存在しないサブディレクトリが要求されたかどうかを確認して を確認し?、その後のすべてを php クエリとして扱いget、書き換えターゲットに追加します。

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 に答える