【发布时间】:2017-04-27 20:41:13
【问题描述】:
我在 slim 框架中有一个项目,我的文件夹结构是这样的:
root web directory
--project
-----api
-----vendor
-----index.php
-----.htaccess
现在,我的问题是我想从我的 API URL 中删除 index.php,这样我就可以使用 http://127.0.0.1/project/api/test 而不是 http://127.0.0.1/project/api/index.php/test。我的 .htaccess 看起来像这样但不起作用: 重写引擎开启
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
【问题讨论】:
标签: php apache .htaccess mod-rewrite