Restler returns a 404 status code if index.php is not included in the URL

First of all, thanks for the RESTLER Framework, this is great!

I installed the Restler API on "http://api.odience.net/". Restler responds with the correct response authority, but returns a 404 status code if I don't include index.php in the url. I installed the .htaccess file, as the examples say, but I can’t understand why it does not respond with the correct status code.

Example:

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

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

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

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 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  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  RewriteRule ^.*$ index.php [QSA,L] # </IfModule> 

To protect the Restler environment, Restler library files are not available on the Internet, and the API_ROOT / index.php file includes them automatically using the require_once command.

Please advise how to configure this setting as expected?

+2
source share
1 answer

Change% {REQUEST_FILENAME} in the .htaccess file to% {DOCUMENT_ROOT}% {REQUEST_FILENAME} (this worked for me) Below is my .htaccess. NTN

 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
source

Source: https://habr.com/ru/post/1433033/


All Articles