阿帕奇相当于lighttpd的url.rewriteonce的?
-
13-09-2019 - |
题
我有我的应用程序入口点是这样的。
/app/index.php <-- this is the main dispatcher.
和应用在特定的文件夹/应用程序/
/app/todo/
/app/calendar/
/app/bugtrack/
每个应用程序文件夹cotains应用的特定文件。
我想通过所有请求unders应用穿过/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]
它适用于/应用/和/应用/ TODO /但没有用于/应用/ TODO /列表/今天的例子。
任何人都可以给我任何的想法怎么办呢?
解决方案
RewriteEngine On
RewriteBase /app
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
这里做的事情是,如果请求不是文件名或一个目录,它重写的index.php。然后检查$_SERVER[REQUEST_URI]
。
不隶属于 StackOverflow