regex - PHP Rest API, Redirect POST router -


i attempting write simple restful php application. attempting write single index.php router.

the .htaccess file have is

<ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_uri} !(\.[a-za-z0-9]{1,5}|/)$ rewriterule api/^(.*)$ api/index.php?_url=/$1 [qsa,l] </ifmodule> 

i added rewritecond %{request_uri} !(\.[a-za-z0-9]{1,5}|/)$ force trailing slash seen here.

calling var_dump($_post); or var_dump($_get); still returns empty array, post values still being dropped. sending , post both returns when evaluating: $_server['request_method'];.

how implement correctly? also, cannot use library , must implement own router.

any assistance or advice appreciated.


edit:


started on scratch:

url requests should http://localhost/api/*

current .htaccess file located in api folder looks this:

rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ controller.php?do=$1 [l,qsa] 

where controller.php sitting in /var/www/api

vhost file in /etc/apache2/sites-available

is titled api.conf

and looks this:

<virtualhost *:*>     servername test.example.com     serveralias www.test.example.com     documentroot /var/www/api/     <directory "/var/www/api/">         allow         allowoverride         options +indexes     </directory> </virtualhost> 

still having same problem:

the requested url /api/something not found on server. 

i solved problem:

apache overwrote default.conf file in sites-available folder when performed update overlooked...

i needed add 000-default.conf

<directory /var/www/>      allowoverride 

i discovered mod_rewrite off:

in_array('mod_rewrite', apache_get_modules()); //or var_dump(apache_get_modules()); 

so reenable:

a2enmod rewrite  service apache2 restart 

hope helps others.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -