简体   繁体   English

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

[英]virtual host alias for multiple laravel applications on single domain

I want my domain to run two separate laravel applications depending the url 我希望我的域根据网址运行两个单独的laravel应用程序

for instance 例如

domain.com to /home/sites/1 domain.com/home/sites/1

domain.com/account to /home/sites/2 domain.com/account/home/sites/2

I have this working, however the laravel instance running on site 2 thinks domain.com/account is the homepage. 我正在工作,但是在站点2上运行的laravel实例认为domain.com/account是主页。

When i goto domain.com/account i see the homepage of site 2 - not the route for setup for /account . 当我转到domain.com/account我看到站点2的主页-而不是/account设置路径。

here is my vhost file 这是我的虚拟主机文件

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

Add this to your custom apache virtualhost file 将此添加到您的自定义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>

Now you need to change .htaccess file of public folder of the alias - 现在,您需要更改别名的公用文件夹的.htaccess文件-

add RewriteBase /directory_name_of_site2/ right after the RewriteEngine On in .htacess file 在.htacess文件中的RewriteEngine On之后立即添加RewriteBase / directory_name_of_site2 /

you can add as many aliases you want just remember to modify the .htaceess file of every projects 您可以添加任意多个别名,只需记住修改每个项目的.htaceess文件即可

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM