Configuration of Apache virtual site and virtual path

I am now configuring a project that consists of
1.user
2.admin
3.superadmin
three parts are independent sites developed by yii. Now the server is required to be configured as follows:

  • xx.xxx.com directly accesses the user
  • xx.xxx.com/admin visits admin site
  • xx.xxx.com/superadmin visits superadmin site

for the first time, I threw admin and superadmin directly under the user folder directory, but the directory management was messy.
the second time I configured user as the server root, admin and superadmin in its parent directory, and apache as the virtual path jump.

  • parent directory

    • user
    • admin
    • superadmin

<VirtualHost *:80>
    ServerAdmin admin.example.com
    DocumentRoot "/data/user"
    ServerName ppp.nppp.cn
    ErrorLog "logs/ppp-error_log"
    CustomLog "logs/ppp-access_log" common
    <Directory "/data/user/">
       Options FollowSymLinks
       AllowOverride All
       Require all granted
    </Directory>
    <IfModule dir_module>
        DirectoryIndex index.php index.html
        Alias /admin  "/data/admin/"
        <Directory /data/admin/>
          Options FollowSymLinks
          AllowOverride All
          Require all granted
        </Directory>
     </IfModule>
   -sharp <IfModule dir_module>
   -sharp    DirectoryIndex index.php index.html
   -sharp     Alias /  "/data/user/"
   -sharp    <Directory /data/user/>
   -sharp      Options FollowSymLinks
   -sharp      AllowOverride All
   -sharp      Require all granted
   -sharp    </Directory>
   -sharp</IfModule>
 </VirtualHost>

this has led to a lot of problems, frequently deployed projects can not find css files, routing errors (I do not know yii, I do not know whether it is a development pot), and so on. Do you have any good solutions for this configuration?

Mar.06,2021

create an entry file in the parent directory at the same level of the three directories, judge the access path in the entry file, and then distribute

Menu