0

I'm trying to make this simple tutorial work on my server but I'm facing a problem which I don't know how to solve.

Suggested directory api is created and only index.php and .htaccess files.

Content of .htaccess file is the same as in tutorial but index.php is altered so it looks like this:

<?php
    $app = new Phalcon\Mvc\Micro();

    $app->get('/api/robots', function() use ($app){
    $response->setJsonContent(array('status' => 'OK', 'messages' => 'This works'));    
    echo "Izvrsena function";
    return $response;
});    

$app->handle();

?>

But when I try to send GET request to address:

         http://SERVER_IP_ADDR/test-api/api/robots  

using hurl.it and I get the following response:

404 Not Found       297 bytes       175 ms

HEADERS

Connection: close
Content-Length: 297
Content-Type: text/html; charset=iso-8859-1
Date: Fri, 27 Mar 2015 17:44:46 GMT
Server: Apache/2.2.15 (CentOS)
BODY view raw

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
  <head>
    <title>404 Not Found</title>
  </head>
  <body>
    <h1>Not Found</h1>
    <p>The requested URL /test-api/api/robots was not found on this server.</p>
    <hr>
      <address>Apache/2.2.15 (CentOS) Server at SERVER_IP_ADDRESS Port 80</address>
    </body>
</html>

I must note that my apache configuration file is a default one.

Alexis King
  • 40,717
  • 14
  • 119
  • 194
justRadojko
  • 239
  • 4
  • 18

1 Answers1

0

1. .htaccess file location

Your .htacces file should be in your test-api/ directory.

2. mod_rewrite enabled

You should enable mod_rewrite in your Apache2 server configuration, here is kinda useful ansewer, but prlly you will have to search for something corresponding to CentOS.

3. Enable Allow-Override

To make it possible for .htacces files to take effect, thanks for providing headers and info about configuration - according to this place, you probably have disabled Allow-Override directive, as of using Apache 2.2. If it is your developing server, feel free to set it to new default as of 2.3.8+ version: Allow-Override All, and .htaccess files should start to work. Server restart will be required.

Community
  • 1
  • 1
yergo
  • 3,965
  • 1
  • 15
  • 39