.htaccess - unable to get $_REQUEST value in php -



.htaccess - unable to get $_REQUEST value in php -

i'm trying create restful api problem i'm unable $_request value. same code work fine on localhost not on server. happen due htaccess code. when api phone call url processapi function called , find out function of api called url

for illustration http://www.domain.com/file.php/api/test

now i'm trying phone call test function in api class

htaccess code redirect url

the first function within api class processapi check wether test function exist or not

but within processapi function $_request value null

this happen on server on localhost work fine

this htaccess code

<ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-s rewriterule ^(.*)$ file.php?request=$1 [qsa,nc,l] rewritecond %{request_filename} -d rewriterule ^(.*)$ file.php [qsa,nc,l] rewritecond %{request_filename} -s rewriterule ^(.*)$ file.php [qsa,nc,l] </ifmodule>

this api code

class api extends rest { private $db = null; public function __construct() { parent::__construct(); } public function processapi() { $func = strtolower(trim(str_replace("api/","",$_request['request']))); if((int)method_exists($this,$func) > 0) { $this->$func(); } else { $error = array('status' => '402', "msg" => 'function not exist'); $this->response($this->json($error), 402); } } } $api = new api; $api->processapi();

by running code onto server got

{"status":"402","msg":"function not exist"}

just because $_request['request'] null

please point me why i'm $_request['request'] = null. htaccess code giving right value in $_request['request']

you should looking @ php's $_server variable instead of $_request.

$_server['request_uri'] should give right uri /api/test

running var_dump on $_server gives more info current request (and server environment processing it)

hope helps!

php .htaccess restful-url

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -