Php 单个域上多个laravel应用程序的虚拟主机别名

Php 单个域上多个laravel应用程序的虚拟主机别名,php,apache,laravel,alias,virtualhost,Php,Apache,Laravel,Alias,Virtualhost,我希望我的域根据url运行两个独立的laravel应用程序 比如说 domain.com至/home/sites/1 domain.com/account至/home/sites/2 我有这个功能,但是在Site2上运行的laravel实例认为domain.com/account是主页 当我转到domain.com/account时,我看到的是站点2的主页,而不是/account的设置路径 这是我的vhost文件 <VirtualHost *:443> ServerName

我希望我的域根据url运行两个独立的laravel应用程序

比如说

domain.com
/home/sites/1

domain.com/account
/home/sites/2

我有这个功能,但是在Site2上运行的laravel实例认为
domain.com/account
是主页

当我转到
domain.com/account
时,我看到的是站点2的主页,而不是
/account
的设置路径

这是我的vhost文件

<VirtualHost *:443>
    ServerName domain.com
    ServerAdmin webmaster@localhost
    UseCanonicalName Off
    DocumentRoot /home/sites/1/public/
    DirectoryIndex index.php

    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    <Directory /home/sites/1/public/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    Alias /account/ /home/sites/2/public/

    <Directory /home/sites/2/public/>
         Require all granted
         Options Indexes Includes FollowSymLinks MultiViews
         AllowOverride All
         Order allow,deny
         Allow from all
         RewriteEngine On
     </Directory>
</VirtualHost>

ServerName域名.com
服务器管理员webmaster@localhost
UseCononicalName关闭
DocumentRoot/home/sites/1/public/
DirectoryIndex.php
选项如下符号链接
允许超越所有
要求所有授权
选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
别名/帐户//主页/站点/2/公共/
要求所有授权
选项索引包括以下符号链接多视图
允许超越所有
命令允许,拒绝
通融
重新启动发动机

将其添加到自定义apache virtualhost文件中

<VirtualHost *:80>

        ServerAdmin xx@xxx.com
        ServerName xxx.com
        DocumentRoot /path/to/site1/public

        Alias /account /path/to/site2/public

        <Directory /path/to/site1/>
           AllowOverride All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

服务器管理员xx@xxx.com
ServerName xxx.com
DocumentRoot/path/to/site1/public
别名/account/path/to/site2/public
允许超越所有
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
现在您需要更改别名的公用文件夹的.htaccess文件-

在.htacess文件中的重写引擎之后添加重写站点2/的基础/目录名


您可以添加任意数量的别名,只需记住修改每个项目的.htaceess文件

对于具有相同文档根的不同域,最好使用Laravel router。您有过这样的做法吗?