简体   繁体   中英

Laravel Virtual Hosts for different Controllers

I am trying to create virtual hosts for different controllers in my Laravel project.

For example

blog.example.com > http://www.example.com/public/blog/
forum.example.com > http://www.example.com/public/cms/forum/

Obviously /blog/ and /cms/forum/ are not actual folders in my /var/www/ directory, they are Laravel re-written "pretty URLs". The folder structure goes only as far as /var/www/LaravelProject/public/

So I can't put in my apache Virtual Host file this because /cms/forum/ does not exist as folders

DocumentRoot "/www/LaravelProject/public/cms/forum/"

you can use sub domain routing as well, example :

Route::domain('{account}.myapp.com')->group(function () {
    Route::get('user/{id}', function ($account, $id) {
        //
    });
});

check it out here Sub-Domain Routing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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