title: Apache configuration to get Laravel API in this url : www.example.com/api
body: <p>I'm not sure this is working or not, I tried but it had no effect. So no errors but something still seems to be wrong.</p>
  
  <p>What I want is that my api (Laravel 5.4) get this root url : www.example.com/api</p>
  
  <p>Here is what fits my idea :</p>
  
  <pre><code>&lt;VirtualHost \*:80&gt;
    ServerName example.com
    DocumentRoot /var/www/vhosts/angular-client
  &lt;/VirtualHost&gt;      
  
  &lt;VirtualHost&gt;     
    ServerName example.com/api
    DocumentRoot /var/www/vhosts/api/public
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Any suggestion is welcome.</p>
  
  <p>Best regards,</p>
  
  <p>Joseph Gremaud</p>
  
  <p>EDIT : 
  Just found out it's easier to use Directory with an alias like this :</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          DocumentRoot    /var/www/spmo
          ServerName      spmo.corp.sftcm.ch
          Header set Access-Control-Allow-Origin "*"
  &lt;Directory /var/www/spmo&gt;
          Require all granted
          DirectoryIndex  index.html
          Options +Indexes
  &lt;/Directory&gt;
  Alias /api /var/www/api/public
  &lt;Directory /var/www/api/public&gt;
          Require all granted
          Options +Indexes
          DirectoryIndex index.php index.html
  &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Now only one problem remains in Laravel configuration because all my routes are redirecting like this : </p>
  
  <p>Expected : spmo.corp.sftcm.ch/api/api/v1/teams -> should give me JSON response.
  Result : spmo.corp.sftcm.ch/api/api/v1/teams -> gave me a 404 error.</p>
  
  <p>I know that this not good to have api/api but i'll change laravel prefixes when I solve my issue.</p>