2016-04-21 110 views
0

在我的網絡服務器上運行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錯誤。

我做錯了什麼?

+0

這似乎更多與阿帕奇相比,而不是Restler。我會建議更改標籤。 – igorsantos07

+0

我不完全確定它是。如果我看看重寫規則和404上顯示的路徑,它就是index.php的URL,所以我認爲Restler試圖加載的東西是真正獲得404返回的東西。 – Gargoyle

回答

0

好的,終於得到了這個工作。有兩個問題。

一個是Restler本身。提供的index.php表示$r->addAPIClass('Home', '');。我不得不刪除第二個空的參數。

另一個是apache。而不是在RewriteRule上說public/index.php我不得不說/dts2/api/public/index.php

一旦我做出這兩個更改,一切都按預期工作。