Multiple Laravel 5 projects on the same domain

后端 未结 5 1461
星月不相逢
星月不相逢 2020-12-18 13:10

I got several Laravel 5 projects running on subfolders, on the same domain.

Each Laravel application is generating it\'s own session cookie, and sometimes it generat

5条回答
  •  醉梦人生
    2020-12-18 14:01

    Each Laravel installation should be located in its own directory.

    Then an alias needs to be defined which points the domain sub-folder to the "child" Laravel folder.

    Example in Apache http.conf:

    
    
        ServerName some.domain
    
        ## Path to laravel domain
        DocumentRoot "/path/to/some/domain/laravel-1/public"
        
            AllowOverride All
        
    
        ## Path to laravel sub-folder
        Alias /laravel-2-path-alias/ "/path/to/some/domain/laravel-2/public"
        
            AllowOverride All
        
    
    
    

    For session cookies, check config\session.php in both installations.

    Root installation config\session.php:

    'cookie' => 'a_unique_name'
    'path' => '/',
    

    Subfolder installation config\session.php:

    'cookie' => 'another_unique_name'
    'path' => '/path/to/sub/folder',
    

    This should ensure that each installation is writing its own unique session cookies. Any cookies generated by the sub application should not interfere with those of the parent.

提交回复
热议问题