我在我的网站根文件夹中创建了一个文件api/v1/index.php
,在这个文件中我创建了webservice。
当我使用url api/v1/index.php/myfunction
调用API时,它会返回结果。其中api/v1/index.php
为文件路径,myfunction
为函数名。
但是我想用url api/v1/myfunction
来调用这个API。但它不是给我的结果(我知道这个url搜索index.php
在myfunction
文件夹)
如何跳过index.php
从我的url或是否有任何其他方法调用API url没有提及文件名。
在根目录下创建一个.htaccess
文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
mod_rewrite
需要在服务器上启用