Lighttpd url.rewrite
我希望在没有 .php 扩展名的情况下访问 /framework/ 文件夹中的所有 .php 文件。在网上搜索了一段时间后,我发现了这一点:
url.rewrite = (
"^/framework/([^?]*)(\?.*)?$" => "$1.php$2",
)
但是当然会产生后果,所以现在如果我访问 /framework/ (localhost/framework/) 它不会加载 index.php 文件 (localhost/framework/索引.php)。相反,它给出了 404。
我如何才能使 @ /framework/ 之外的任何文件夹加载目录index.php 文件?
所以喜欢
本地主机/框架/控制器/
将是
本地主机/framework/controller/index.php
等。
我对此很陌生,所以如果你能向我解释你做了什么,那就太好了。正如你所看到的,我在正则表达式方面并不是最好的。
I wanted all my .php files in my /framework/ folder to be accessed without the .php extension. After scouring the web for a while, I found this:
url.rewrite = (
"^/framework/([^?]*)(\?.*)?$" => "$1.php$2",
)
But of course there were consequences to that, so now if I access /framework/ (localhost/framework/) it doesn't load the index.php file (localhost/framework/index.php). Instead, it gives a 404.
How do I make it so that any folder beyond and @ /framework/ to load the directories index.php file?
So like
localhost/framework/controller/
would be
localhost/framework/controller/index.php
etc.
I'm rather new to this, so if you could explain to me what you did, that would be great. As you can see I'm not the best with regex.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
专门为带有尾部斜杠的路径添加一条规则:
下面是正则表达式工作原理的详细说明:
Add a rule specifically for paths with a trailing slash:
And here's a breakdown of how the regular expression works: