簡體   English   中英

如果URL中未包含index.php,Restler返回404狀態代碼

[英]Restler returns 404 status code if index.php is not included in URL

首先,感謝RESTLER Framework,這太好了!

我已經在“ http://api.odience.net/”上設置了Restler API。 Restler會使用正確的響應正文進行響應,但是如果我不在URL中包含index.php,則會返回404狀態代碼。 我已經按照示例中的說明設置了.htaccess文件,但無法弄清楚為什么它沒有使用正確的狀態代碼進行回復。

例:

*-訪問/sandbox/about/products/en.json (並傳遞一些GET變量+調用sandbox.php的about方法)將返回404標頭,即使返回的主體數據正確無誤!

*-如果我們將“ index.php”文件添加到url中,標題就可以了!

嘗試:訪問/index.php/sandbox/about/products/en.json (使用相同的GET vars)

這是我對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庫文件不可用於Web,並且API_ROOT / index.php文件通過“ require_once”命令自動將它們包括在內。

請告知如何使此設置按預期工作?

將.htaccess文件中的%{REQUEST_FILENAME}更改為%{DOCUMENT_ROOT}%{REQUEST_FILENAME}(對我有用)這是我的.htaccess文件內容。 高溫超導

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] 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM