title: My localhost doesn't use the right path
body: <p>I'm making a AngularJS app and I'm using a Slim API. I use my API to get data from my DB. </p>
  
  <p>I was testing my app and I noticed something. I have my app in my localhost, but in a server to and they use the exact same code. I use this code to call my API:</p>
  
  <pre><code>angular.module('appDatabaseCtrl', [])
  .controller('databaseCtrl', ['$scope','$routeParams', '$http', '$log',
      function($scope, $routeParams, $http, $log){
          $scope.testDatabaseItems = function(){
              $http.get('/api/items').success(function(data) {
                  $log.info("succes!");
                  $log.log(data);
              })
              .error(function (data, status){
                  $log.error("error!");
                  $log.log(data);
              });
          };
          $scope.testDatabaseItemById = function(){
              $http.get('/api/items/' + $scope.id).success(function(data) {
                  $log.info("succes!");
                  $log.log(data);
              })
              .error(function (data, status){
                  $log.error("error!");
                  $log.log(data);
              });
          };
      }
  ]);
  </code></pre>
  
  <p>Here is my "index.php" file in my Slim API:</p>
  
  <pre><code>&lt;?php
  use \Psr\Http\Message\ServerRequestInterface as Request;
  use \Psr\Http\Message\ResponseInterface as Response;
  
  //nécessite Slim
  require 'vendor/autoload.php';
  
  
  //Instancie une app de Slim
  $app = new \Slim\App;
  
  //Associe type de requête avec fonction et paramêtres
  $app-&gt;get('/items', 'getItems');
  $app-&gt;get('/items/{id:\d+}', 'getItemById');
  
  //Démarre l'application
  $app-&gt;run();
  
  // Accès à la base de données
  function DB_Connection() {  
      $dbhost = "localhost";
      $dbuser = "kevdug_angularjs";
      $dbpass = "*****************";
      $dbname = "angularjs";
      $dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);  
      $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      return $dbh;
  }
  
  function getItems() {
      $sql = "select * FROM aj_items";
      try {
          $db = DB_Connection();
          $stmt = $db-&gt;query($sql);  
          $list = $stmt-&gt;fetchAll(PDO::FETCH_OBJ);
          $db = null;
          echo json_encode($list);
      } catch(PDOException $e) {
          echo '{"error":{"text":'. $e-&gt;getMessage() .'}}'; 
      }
  }
  
  function getItemById(Request $request, Response $response, $args) {
      $id = $args["id"];
      $sql = "select * FROM aj_items WHERE id=".$id;
      try {
          $db = DB_Connection();
          $stmt = $db-&gt;query($sql);  
          $list = $stmt-&gt;fetchAll(PDO::FETCH_OBJ);
          $db = null;
          echo json_encode($list);
      } catch(PDOException $e) {
          echo '{"error":{"text":'. $e-&gt;getMessage() .'}}'; 
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>If I use the "testDatabaseItems" function in my app on my server, it perfectly works, but when I try using it in my localhost, I get an 404 error:</p>
  
  <blockquote>
    <p>"NetworkError: 404 Not Found - <a href="http://localhost:8080/api/items" rel="nofollow">http://localhost:8080/api/items</a>"</p>
  </blockquote>
  
  <p>I know that the reason why I get a 404 error page is simply that the address should be:</p>
  
  <blockquote>
    <p>localhost:8080/angularjs/api/items</p>
  </blockquote>
  
  <p>What I want is that in my localhost version, it use the good path but that I don't need to have a different code for my localhost version and my server version.</p>
  
  <p>An other strange thing is that If I go to <a href="http://kevdug.webfactional.com/api/items" rel="nofollow">http://kevdug.webfactional.com/api/items</a>, I get my json object like I expect, but in my localhost, I need to got to "(my localhost address)/api/index.php/items". I need to specify the "index.php" file for some reason and I would like to not need to do that.</p>