web服务-如何调用我的index.php没有文件名


web services - How to call my index.php without file name

我在我的网站根文件夹中创建了一个文件api/v1/index.php,在这个文件中我创建了webservice。

当我使用url api/v1/index.php/myfunction调用API时,它会返回结果。其中api/v1/index.php为文件路径,myfunction为函数名。

但是我想用url api/v1/myfunction来调用这个API。但它不是给我的结果(我知道这个url搜索index.phpmyfunction文件夹)

如何跳过index.php从我的url或是否有任何其他方法调用API url没有提及文件名。

在根目录下创建一个.htaccess文件:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

mod_rewrite需要在服务器上启用