1

我有这样的应用程序入口点。

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

和 /app/ 下的应用程序特定文件夹

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

每个应用程序文件夹都包含应用程序特定的文件。

我想通过应用程序下的所有请求通过/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 回答