Two document root in one vhost

Discussion in 'ISPConfig 3 Priority Support' started by pawan, Nov 19, 2018.

  1. pawan

    pawan Member HowtoForge Supporter

    I am trying to install yii-advance-app,
    which in its guide shows two document roots.
    for example when I am installing the application in web root
    the folder structure is like below:


    We then update the httpd-vhosts.conf to include the front and back ends.
    DocumentRoot “C:/wamp/www/yii/advanced/frontend/web”

    DocumentRoot “C:/wamp/www/yii/advanced/backend/web”

    So in my case
    I want to achieve
    to open at
    to open at

    As I took a look at vhost file,
    there are reference for directory /var/www/clients/client2/web217/web at multiple places
    so How I can add references for both without actually making a mess of it.
    Last edited: Nov 19, 2018
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    A vhost cannot have more than one document root, as far as I know. What You try to achieve is to map two subdomains to different directories. This can be achieved by using vhost subdomains in ISPConfig.
  3. pawan

    pawan Member HowtoForge Supporter

    Okay - may be I am trying to achieve something which is not practical.
    Let me explain.
    I have uploaded the Yii2 advanced code in my web directory -
    the folder structure is like
    so now to access the frontend application
    I have to type -
    and to access the backend
    I have to type
    what I am looking is How can rewrite path or something
    so for frontend I can access
    with (without typing the frontend/web/index.php
    and similary for backend
    with say (and not typing /backend/web/index.php)
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The first question is, does the app that you install support this (does it support that you shorten the path and map a different subdomain on a partial URL of the app)? If yes, then you can do it with vhost subdomains in ISPConfig like I mentioned in my first answer.
  5. pawan

    pawan Member HowtoForge Supporter

    Thanks Till,
    I got the solution elsewhere using .htaccess
    here is what I got.
    Options +FollowSymlinks
    RewriteEngine On
    # deal with admin first
    RewriteCond %{REQUEST_URI} ^/(admin)
    RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
    RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L]
    RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css)/
    RewriteCond %{REQUEST_URI} ^/(admin)
    RewriteRule ^.*$ backend/web/index.php [L]
    RewriteCond %{REQUEST_URI} ^/(assets|css)
    RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
    RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
    RewriteRule ^js/(.*)$ frontend/web/js/$1 [L]
    RewriteRule ^images/(.*)$ frontend/web/images/$1 [L]
    RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css)/
    RewriteCond %{REQUEST_URI} !index.php
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ frontend/web/index.php
    till likes this.

Share This Page