我有一个用PHP编写的litle应用程序,使用apache。我在.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,NC,L]
</IfModule>
所以,基本上我想在index.php文件中处理所有uris。它工作得很好,我的问题是当我尝试匹配一个uri并且有一个.php
文件时,如果我有一个api.php
文件,那么uri { {1}}抛出http://localhost/app-name/api
那么,我怎样才能处理404 error
的所有uris?为什么指令index.php
无法正常工作?
答案 0 :(得分:1)
尝试更新代码并关闭multiviews
。默认情况下,它会查找扩展名与您输入的文件相同的文件。
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,NC,L]
</IfModule>
旁注,我从未见过实际上想要使用此功能的任何人。