.htaccess - PHP Slim Framework: The requested URL was not found on this server -


for 1 of projects, using slim framework http://www.slimframework.com/ create restful apis in php.

i did manual install framework copying in php project folder using instructions @ https://github.com/slimphp/slim.

later updated .htaccess well.

for project, have following directory structure

project\ ----slim\ ----tests\ ----index.php ----.htaccess 

for this, call i.e. http://someip/project/ works me. fetches standard "welcome slim! congratulations! slim application running. if first time using slim, start "hello world" tutorial." however, post/patch/delete , other not working. not hello. gives not found error.

http://someip/project/hello/:name requested url /project/hello/:name not found on server.

http://someip/project/post requested url /project/post not found on server.

updated .htaccess file :

rewriteengine on rewritebase /project/ rewritecond %{request_filename} !-f rewriterule ^ index.php [qsa,l] 

still failing.

when made changes apache config file allowoverride = all, failed call on index.php. sure, not mapping .htaccess.

i still clueless changes need make .htaccess or other file working.

here code:

\slim\slim::registerautoloader();  /**  * step 2: instantiate slim application  *  * example instantiates slim application using  * default settings. however, configure  * slim application passing associative array  * of setting names , values application constructor.  */ $app = new \slim\slim();  /**  * step 3: define slim application routes  *  * here define several slim application routes respond  * appropriate http request methods. in example, second  * argument `slim::get`, `slim::post`, `slim::put`, `slim::patch`, , `slim::delete`  * anonymous function.  */  // route $app->get(     '/',     function () {         $template = "hi";         echo $template;     } );  //$app->get( //    '/v1/status/', //    function() { //        echo "status"; //    } //); // $app->get('/hello/:name', function ($name) {     echo "hello, $name"; });  // post route $app->post(     '/post',     function () {         echo 'this post route';     } );  // put route $app->put(     '/put',     function () {         echo 'this put route';     } );  // patch route $app->patch('/patch', function () {     echo 'this patch route'; });  // delete route $app->delete(     '/delete',     function () {         echo 'this delete route';     } );  /**  * step 4: run slim application  *  * method should called last. executes slim application  * , returns http response http client.  */ $app->run(); 

the following steps worked me :

changes in apache2.conf

1. path of running apache     ps -ef | grep apache    append -v argument path     /usr/sbin/apache2 -v | grep server_config_file  2. naviagte apache2.conf     vi /etc/apache2/apache2.conf  3. update file replace "allowoverride none" "allowoverride all"     <directory /var/www/>             options indexes followsymlinks             allowoverride             require granted     </directory> 4. restart apache2 after     service apache2 restart    or     apachectl -k graceful 

changes in .htaccess

rewriteengine on rewritebase /  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^ index.php [l] 

changes in .htaccess inside subdirectory

rewriteengine on rewritebase /project rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [qsa,l] 

enable mod_rewrite apache 2.2

1. type following command in terminal     a2enmod rewrite 2. restart apache2 after     service apache2 restart 

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 -