php - 如何让 Slim Framework 工作而不必在 URL 中放入/index.php?

标签 php apache .htaccess url-rewriting slim

我正在为 PHP 实现 Slim Framework,一切似乎都运行良好。但是,我可以让它工作的唯一方法是将/index.php 放在 URL 中,如下所示:

http://www.example.com/index.php/members/1

我希望它像这样工作:

http://www.example.com/members/1

我感觉它与我的 .htaccess 有关,但我不确定。这是我的 .htaccess:

RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^ ./index.php [QSA,L]
RewriteRule ^ . [QSA,L]

最佳答案

恢复注释 (#) 行并删除另一行应该会有所帮助。当您下载 Slim Framework 时,它 originally had this in the .htaccess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ ./index.php [QSA,L]

另外,你应该 learn about writing rewrite rules ,因为没有它你走不了多远。

关于php - 如何让 Slim Framework 工作而不必在 URL 中放入/index.php?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11569445/

相关文章:

apache - 在 PHP 中从 .htaccess 重写 URL 获取查询字符串参数

php - MySQL事务-如何分组?

javascript - 如何使用 javascript 创建动态单选按钮

php - MySQL 连接无法在 AWS EC2 上运行

regex - 通过 htaccess 中的正则表达式删除文件夹

php - 如何使用 .htaccess 从 url 中删除扩展名而不使用尾部斜杠?

node.js - 生产中的 Ember CLI 与 Apache 服务器上的 Sails.js API 通信时出现问题

php - javascript - 如何将 json 数据分配给 HTML 元素并发送到 API onclick?

python - 当 html 表单允许文件上传时,Django 以 "generator raised StopIteration"停止

apache - 使用apache rewrite时如何隐藏URL更改?