我正在为 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/