Restler设置不起作用
问题描述:
在我的网络服务器上运行Apache/2.2.26 (Unix) DAV/2 PHP/5.4.24 mod_ssl/2.2.26 OpenSSL/0.9.8y
我试图设置Restler,但它似乎无法正确处理index.php。这是一个Web应用程序的设置与httpd.conf中,看起来像这样:Restler设置不起作用
Alias "/dts2" "/usr/local/WebApps/DTS/root"
<Directory "/usr/local/WebApps/DTS/root">
AllowOverride All
Options -Indexes FollowSymLinks
</Directory>
于是我走进那个“根”目录,并运行此命令安装restler:
composer create-project restler/application=dev-basic api --prefer-dist
后即,在“API”目录创建我的.htaccess文件看起来像这样:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ public/index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
php_flag display_errors On
</IfModule>
而且,最后当我试图访问“https://..../dts2/api/Home/ “要获得restler提供的成功消息,我会收到404错误。
我做错了什么?
答
好的,终于得到了这个工作。有两个问题。
一个是Restler本身。提供的index.php表示$r->addAPIClass('Home', '');
。我不得不删除第二个空的参数。
另一个是apache。而不是在RewriteRule上说public/index.php
我不得不说/dts2/api/public/index.php
。
一旦我做出这两个更改,一切都按预期工作。
这似乎更多与阿帕奇相比,而不是Restler。我会建议更改标签。 – igorsantos07
我不完全确定它是。如果我看看重写规则和404上显示的路径,它就是index.php的URL,所以我认为Restler试图加载的东西是真正获得404返回的东西。 – Gargoyle