Restler返回404状态code如果URL中不包括的index.php [英] Restler returns 404 status code if index.php is not included in URL

查看:125
本文介绍了Restler返回404状态code如果URL中不包括的index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,感谢RESTLER框架,很精彩!

First of all, thanks for RESTLER Framework, it is wonderful!

我已经设置了Restler API的http://api.odience.net/。
Restler有正确的反应身体反应,但返回404状态code,如果我不包含在URL中的index.php。我已经设置了.htaccess文件作为例子说,但我想不出为什么它不正确的状态code回复。

I've set up Restler API on "http://api.odience.net/" . Restler responds with correct response body but returns a 404 status code if I don't include index.php in the url. I've set up the .htaccess file as said in the examples but I can't figure out why it doesn't reply with the correct status code.

例如:

* - 访问<一个href=\"http://api.odience.net/sandbox/about/products/en.json?name=odience.net%C2%A6works%20&slogan=connect.&url=http://www.odience.net/store\"相对=nofollow> /沙箱/约/产品/ en.json (并传递一些GET变量+调用sandbox.php的约法)返回即使返回的身体数据的404头是正确的!

*- Accessing /sandbox/about/products/en.json (and passing some GET variables + calling the about method of sandbox.php) returns a 404 header even if the body data returned is correct!

* - 如果我们的的index.php文件添加到URL,标题是精品!

*- If we add the "index.php" file to the url, headers are fine!

尝试:
访问<一个href=\"http://api.odience.net/index.php/sandbox/about/products/en.json?name=odience.net%C2%A6works%20&slogan=connect.&url=http://www.odience.net/store\"相对=nofollow> / index.php文件/沙箱/约/产品/ en.json (相同GET瓦尔)

Try: Access /index.php/sandbox/about/products/en.json (with same GET vars)

下面是Restler根目录我详细的.htaccess文件:

Here is my detailed .HTACCESS file for the Restler root directory:

## 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命令。

To secure Restler framework, the Restler library files are not available to the web and the API_ROOT/index.php file includes them automatically with a "require_once" command.

请指教如何使设置生效预期?

Please advise how to make this setup work as expected?

推荐答案

更改%{} REQUEST_FILENAME在.htaccess文件到%{DOCUMENT_ROOT}%{} REQUEST_FILENAME(它的工作对我来说)下面是我的.htaccess文件的内容。 HTH

Change %{REQUEST_FILENAME} in .htaccess file to %{DOCUMENT_ROOT}%{REQUEST_FILENAME} (it worked for me) Below is my .htaccess file content. 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] 

这篇关于Restler返回404状态code如果URL中不包括的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆