【发布时间】:2015-10-28 11:28:10
【问题描述】:
我有一个包含两个应用程序的项目:一个前端(在 AngularJs 中)和一个后端(在 Phalcon 中)。我的服务器文档根目录有两个文件夹和一个 htaccess:
public_html
- api
- controllers
- index.php
- app
- .htaccess
.htaccess 有如下配置:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/(.*)$ api/index.php?_url=/$1 [QSA,L]
</IfModule>
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
所以,当我向http://mydomain/api/sessions 发送 POST 请求(例如)时,结果是 404 not found。路由器配置为:
$router->addPost('/sessions', array(
'controller' => 'sessions',
'action' => 'post'
));
在我的本地主机中,此配置可以正常工作。但是,在我的 VPS 中没有。 有什么想法吗?
更新 1:
如果我不使用任何 REST 服务,则通过 http://mydomain/api 访问 Phalcon 索引控制器已加载。
更新 2:
如果我尝试使用像http://mydomain/api/index.php?_url=/licenses 这样的 Phalcon url 访问 REST 服务,效果很好。
【问题讨论】:
标签: apache .htaccess mod-rewrite phalcon