Apache 相当于 lighttpd url.rewriteonce?
我的应用程序入口点是这样的。
/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 。
任何人都可以告诉我该怎么做吗?
I have my application entry point like this.
/app/index.php <-- this is the main dispatcher.
And application specific folders under /app/
/app/todo/
/app/calendar/
/app/bugtrack/
Each application folder cotains application specific files.
I would like to pass all requests unders app to pass through /app/index.php.
So that.
/app/todo/list/today -> goes to /app/index.php
/app/ -> goes to /app/index.php
/app/bugtrack/anything/else goes to /app/index.php
On my lighttpd test machine I can easily do it it by writing a rule like this.
url.rewrite-once = (
"^\/app\/todo\/*" => "/app/index.php",
"^\/app\/calendar\/*" => "/app/index.php",
"^\/app\/bugtrack\/*" => "/app/index.php",
)
Now need to make it work on Apache using .htaccess and mod_rewrite.
But no matter what I do, it's not working.
I wrote the following in /app/.htaccess
RewriteEngine on
RewriteRule .* index.php [QSA]
It works for /app/ and /app/todo/ but fails for /app/todo/list/today for example.
Anyone can give me any idea how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样做的作用是,如果请求不是文件名或目录,则将其重写为index.php。 然后检查
$_SERVER[REQUEST_URI]
。What this does is if the request is not a filename or a directory, rewrite it to index.php. Then check
$_SERVER[REQUEST_URI]
.