Virtualhost de Apache para SPA de Vue y API con PHP

<VirtualHost *:9080>
    # Vue.js Single Page Application
    DocumentRoot /var/www/app/dist
    <Directory "/var/www/app/dist">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted

        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.html [L]
    </Directory>

    # PHP API
    Alias "/api" "/var/www/app/api"
    <Directory "/var/www/app/api">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted

        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^ index.php [L]
    </Directory>
</VirtualHost>

En un caso como este todas las peticiones a la API van a dominio.com/api/XXXXX

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.