【问题标题】:virtual host alias for multiple laravel applications on single domain单个域上多个 laravel 应用程序的虚拟主机别名
【发布时间】:2017-09-18 15:47:20
【问题描述】:

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

例如

domain.com/home/sites/1

domain.com/account/home/sites/2

我有这个工作,但是在站点 2 上运行的 laravel 实例认为 domain.com/account 是主页。

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

这是我的虚拟主机文件

<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>

【问题讨论】:

  • 对于具有相同文档根目录的不同域,最好使用 Laravel 路由器。
  • 你有没有得到这个工作?

标签: php apache laravel alias virtualhost


【解决方案1】:

将此添加到您的自定义 apache 虚拟主机文件中

<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>

现在您需要更改别名的公用文件夹的.htaccess文件 -

在 .htacess 文件中的 RewriteEngine On 之后添加 RewriteBase /directory_name_of_site2/

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

【讨论】:

    猜你喜欢
    • 2011-09-24
    • 2011-11-20
    • 2015-11-24
    • 1970-01-01
    • 2022-09-28
    • 1970-01-01
    • 2023-04-10
    • 2016-03-31
    • 2018-08-24
    相关资源
    最近更新 更多