2012-01-09 8 views
2

まず、RESTLER Frameworkのおかげで素晴らしいです!URLにindex.phpが含まれていない場合、Restlerは404ステータスコードを返します

「http://api.odience.net/」にRestler APIを設定しました。 Restlerは正しい応答本文で応答しますが、URLにindex.phpが含まれていないと404ステータスコードを返します。私は例で述べたように.htaccessファイルを設定しましたが、なぜ正しい状態コードで応答しないのかわかりません。

例:

* - /sandbox/about/products/en.jsonへのアクセス(とsandbox.php約メソッドを呼び出す+いくつかのGET変数を渡すには)身体データが返された場合でも、404ヘッダーを返しますが正しいです!

* - 「index.php」ファイルをURLに追加すると、ヘッダーは正常です!

試してみてください(同じGETのVARS付き) アクセス/index.php/sandbox/about/products/en.json

ここではRestlerルートディレクトリのための私の詳細の.htaccessファイルです:

## Can be commented out if causes errors. 
Options +FollowSymLinks 
<IfModule mod_rewrite.c> 
    RewriteEngine On 

## Begin - Rewrite rules to block out some common exploits. 
# If you experience problems on your site block out the operations listed below 
# This attempts to block the most common type of exploit `attempts` to Joomla! 
# 
# Block out any script trying to base64_encode data within the URL. 
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR] 
# Block out any script that includes a <script> tag in URL. 
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] 
# Block out any script trying to set a PHP GLOBALS variable via URL. 
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] 
# Block out any script trying to modify a _REQUEST variable via URL. 
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) 
# Return 403 Forbidden header and show the content of the root homepage 
RewriteRule .* index.php [F] 
# 
## End - Rewrite rules to block out some common exploits. 
## 
# Uncomment following line if your webserver's URL 
# is not directly related to physical file paths. 
# Update Your API Directory (just/for root). 
## 
RewriteBase/

# 
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
# 
# If the requested path and file is not /index.php and the request 
# has not already been internally rewritten to the index.php script 
RewriteCond %{REQUEST_URI} !^/index\.php 
# and the request is for something within the reg server folder, 
# or for the site root, or for an extensionless URL, or the 
# requested URL ends with one of the listed extensions 
RewriteCond %{REQUEST_URI} /server/|(/[^.]*|\.(php|html?|json|xml|feed|pdf|vcf|raw))$ [NC] 
# and the requested path and file doesn't directly match a physical file 
RewriteCond %{REQUEST_FILENAME} !-f 
# and the requested path and file doesn't directly match a physical folder 
RewriteCond %{REQUEST_FILENAME} !-d 
# internally rewrite the request to the index.php script 
RewriteRule ^.*$ index.php [QSA,L] 
# 

</IfModule> 

Restlerの枠組みを確保するために、Restlerライブラリファイルがありませんウェブで利用可能であり、API_ROOT/index.phpファイルには自動的に「require_once」コマンドが含まれています。

この設定を期待どおりにするにはどうすればよいですか?

+0

私は現在、それを見ています。上記の '.htaccess'ファイルは、RewriteBaseを正しく設定することで、サブディレクトリでホストされているapiで動作します。私のlocalhostで同じ問題を再作成しようとしています。問題は、 '#Return 403 Forbiddenヘッダーのためにあり、ルートホームページの内容を表示することがあります RewriteRule。* index.php [F]'。悪用修正の書き換え全体をコメントしたり削除したりして、それが機能するかどうか試してみてください。 – Luracast

+0

@Luracast脆弱性修正プログラムを削除しましたが、同じ問題が発生しました。 ここに私のディレクトリ構造があります: -html --api --- public <==パブリックindex.phpとサブドメインポイントが含まれています。 --- lib ---- restler <== RESTLERファイルが含まれています --- conf –

+0

私のサーバーで問題を再現できませんでした。あなたが使用しているrestler、apache、phpのバージョンを教えてください – Luracast

答えて

0

.htaccessファイル内の%{REQUEST_FILENAME}を%{DOCUMENT_ROOT}%{REQUEST_FILENAME}に変更しました。(これは私のために働いた)以下は私の.htaccessファイルの内容です。 HTH

RewriteEngine On 
RewriteBase/
RewriteRule ^$ index.php [QSA,L] 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php [L,QSA] 
+0

申し訳ありませんが、ソリューションで問題が解決されませんでした。 –

+0

@Luracast:Restler:2.1.3; Apache PHP:5.2.17 –

関連する問題