4

特定のサブディレクトリ (webroot とは異なる) の書き換えルールを取得する際にいくつかの問題があり、それらをどこに置くべきか途方に暮れています。

/var/www/ (WordPress を含む webroot) /var/www/subdirectory (独自の書き換えルールを必要とする他のアプリを含む)

以下は、webroot ディレクトリ (/var/www またはhttp://mywebsite.com )にある WordPress のルールです。

$HTTP["host"] =~ "mywebsite.com" {
  url.rewrite-final = (

    # Exclude some directories from rewriting
    "^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",

    # Exclude .php files at root from rewriting
    "^/(.*.php)" => "$0",

    # Handle permalinks and feeds
    "^/(.*)$" => "/index.php/$1"
  )
}

次に、webroot のサブディレクトリ (/var/www/subdirectory またはhttp://mywebsite.com/subdirectory ) に次のルールで配置する 2 つ目のアプリを作成します。

url.rewrite = (
    "(index.php|test.php|favicon.ico)" => "/$1",
    "(css|files|img|js)/(.*)" => "/$1/$2",
    "^([^\?]*)(\?(.+))?$" => "/index.php?url=$1&$3",
)

私が必要とするのは、上記の #Excluded ルール (および /subdirectory) の他のディレクトリを除くすべてに適用される上記の書き換えルールの最初のセット、次に /subdirectory のみに適用される 2 番目のルールのセットです。

オンラインのどこかのブログから WordPress の最初のルール セットを取得しましたが、必ずしも必要なものではない可能性があります (「mywebsite.com」の一致に関しては、おそらく簡略化できます)。

私は複数のバリエーションを試してみましたが(ほとんどの場合、わずかに関連するランダムなフォーラム投稿に導かれて暗闇の中で刺すだけです)、頭を包み込むことはできません。

では、ルートの Wordpress ルールを維持しながら、2 番目のルール セットをサブディレクトリに適用するにはどうすればよいでしょうか?

注: サブドメインにはアクセスできません (簡単すぎます)。

4

1 に答える 1

2

何を表現したいのかよくわかりません - 現在のルールセットが何をしているのかを説明します。

これを使用しないでください。代わりにユーザーが一度だけ書き換えます

url.rewrite = (

index.php と test.php (foo-test.php も含む) を webroot にマップし続けます。

"(index.php|test.php|favicon.ico)" => "/$1",

URLにcss、files、tmp、またはjsを含むサブフォルダーまたはファイルを書き換えて、webrootに戻します

"(css|files|img|js)/(.*)" => "/$1/$2",

これは、Webroot 内のすべてのものに一致し (サブディレクトリはありません!)、get 要求を保持します。

"^([^\?]*)(\?(.+))?$" => "/index.php?url=$1&$3",
)

更新 これでうまくいくはずです(未テスト)

url.rewrite-once = (
"^/subdir/(?:index.php|test.php|favicon.ico)" => "$0",
"^/subdir/(?:.+/)?(css|files|img|js)/(.*)" => "/subdir/$1/$2", #update #2
"^/subdir/(?:/(?:.+/))?([^\?]*)(?:\?(.+))?$" => "/subdir/index.php?url=$1&$2",

"^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
"^/(.*.php)" => "$0",
"^/(.*)$" => "/index.php/$1"
)
于 2012-09-17T20:24:02.050 に答える