'Apache Alias - Yii2

I'm using Yii2 advanced template and I wonder if someone has a solution for the following scenario.

The web application has both frontend and backend interfaces.

The normal setup would be using Virtualhosts to setup sub domains:

  • frontend.domain.com
  • backend.domain.com

The desired setup is:

  • domain.com = frontend
  • domain.com/backend

I've been playing around with Apache Alias but no luck, any thoughts would be appreciated.

Below is my Virtualhost configs for reference:

<VirtualHost *:443>
    ServerName domain.com
    ServerAlias *.domain.com
    DocumentRoot "/var/www/app/frontend/web"

    Alias "/backend" "/var/www/app/backend/web"

    <Directory "/var/www/app/backend/web">
        # use mod_rewrite for pretty URL support
        RewriteEngine on
        RewriteBase /backend
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php

        # use index.php as index file
        DirectoryIndex index.php

        # ...other settings...
        # Apache 2.4
        Require all granted

        ## Apache 2.2
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>


Solution 1:[1]

I don't know if it is possible to achieve what you want by Apache config. But you could create a symbolic link in the frontend folder linking to the web directory in backend:

ln -s /path/to/backend/web /path/to/frontend/web/backend

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 schmauch