鍍金池/ 問答/Java  PHP  Linux/ Apache虛擬站點(diǎn)和虛擬路徑的配置問題

Apache虛擬站點(diǎn)和虛擬路徑的配置問題

我現(xiàn)在在配置一個(gè)項(xiàng)目,這個(gè)項(xiàng)目由三個(gè)部分組成
1.user
2.admin
3.superadmin
三個(gè)部分都是由yii開發(fā)的獨(dú)立站點(diǎn),現(xiàn)在需求方要求服務(wù)器作如下配置:

  • xx.xxx.com直接訪問user端
  • xx.xxx.com/admin訪問admin站點(diǎn)
  • xx.xxx.com/superadmin訪問superadmin站點(diǎn)

第一次我直接將admin和superadmin丟在user文件夾目錄下面,但是這樣目錄管理混亂。
第二次我將user配置為服務(wù)器根目錄,admin和superadmin放在它的父目錄中,apache作虛擬路徑跳轉(zhuǎn)。

  • 父目錄

    • 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>
   # <IfModule dir_module>
   #    DirectoryIndex index.php index.html
   #     Alias /  "/data/user/"
   #    <Directory /data/user/>
   #      Options FollowSymLinks
   #      AllowOverride All
   #      Require all granted
   #    </Directory>
   #</IfModule>
 </VirtualHost>

這樣導(dǎo)致了很多問題,經(jīng)常部署的項(xiàng)目找不到css文件,路由出錯(cuò)(我不懂yii,我也不知道是不是開發(fā)的鍋)等等,請(qǐng)問大家這樣的配置有什么好的解決方案嗎?

回答
編輯回答
萢萢糖

三個(gè)目錄的同級(jí)下,即父目錄里創(chuàng)建一個(gè)入口文件,在入口文件里對(duì)訪問的路徑進(jìn)行判斷,然后分發(fā)

2017年3月11日 03:38