1

このようなアプリケーション エントリ ポイントがあります。

/app/index.php <-- this is the main dispatcher.

/app/ の下のアプリケーション固有のフォルダー

/app/todo/
/app/calendar/
/app/bugtrack/

各アプリケーション フォルダには、アプリケーション固有のファイルが含まれています。

app の下のすべてのリクエストを /app/index.php を通過するように渡したいと思います。

となることによって。

/app/todo/list/today -> goes to /app/index.php
/app/ -> goes to /app/index.php
/app/bugtrack/anything/else goes to /app/index.php

私の lighttpd テスト マシンでは、このようなルールを書くことで簡単に実行できます。

url.rewrite-once = (
    "^\/app\/todo\/*"   => "/app/index.php",
    "^\/app\/calendar\/*"   => "/app/index.php",
    "^\/app\/bugtrack\/*"   => "/app/index.php",
)

.htaccess と mod_rewrite を使用して Apache で動作させる必要があります。

しかし、私が何をしても、うまくいきません。

/app/.htaccess に以下を書きました

RewriteEngine on
RewriteRule .* index.php [QSA]

/app/ と /app/todo/ では機能しますが、たとえば /app/todo/list/today では失敗します。

誰でもそれを行う方法を教えてもらえますか?

4

1 に答える 1

1
RewriteEngine On
RewriteBase /app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

これが行うことは、リクエストがファイル名でもディレクトリでもない場合、それを index.php に書き換えることです。次に、チェックし$_SERVER[REQUEST_URI]ます。

于 2009-04-22T09:54:30.910 に答える