I have a project that has three "subdomains". One is the main web site, one is a mobile optimized version and one is the administration. Traditionally, I've had each one as a sub-domain. www, mobile, and admin.
What is the best way to approach this in laravel? What if I want to make them their own projects? How would I share the same model (and keep migrations with the model, etc). Or is this possible to do in the same one project?
This would make sense if I used the same domain during development when I do in production. In production, I may be www.example.com but in development, I may reference it as www.example.dev (for my local dev environment). Would using environment variables make sense here?
But when I go to admin.domain.com, the index of the main site is loaded, I'd like to see the admin landing page instead.
Also, when I go to admin.domain.com/contact I don't want to see the contact from the main site but the one from the admin instead.
When I go to admin.domain.com/about I should get a 404 page.
How can I do that?
Thanks
@bearcodi This should work for everyone, but I'd recommend putting the domains in config/app.php so it's consistent with how other app related variables are stored. Directly accessing via env() isn't considered great.
Here, you have grouped the sub-domain and its fine. So, can we group multiple top domains not sub-domain the same way so if one Laravel can handle main (top) multiple domain at the same place?
if anyone found a solution let me know as i am looking for a multi-domain multi site to manage all 30 websites in one dashbaord with 3 different templates to choose from
@webjobs how did you do it? I have similar project multiple domains each with different color scheme, logo, templates etc but for now all hosted on single server, in later phase if users of anyone of them gets big i will host in different server
Hello everyone, @bearcodi answer seems to be a potential solution, but as it's 5 years old I'd like to ask if there is something better or cleaner I could use nowadays.
Thanks in advance.
I want to host my Laravel project in multiple domain and thiar sub domain too how will it's APP_URL configure ?
like abc.com test1.abc.com test2.abc.com
xyz.com test1.xyz.com test2.xyz.com
then what will APP_URL configurations because of URL() , route(), and assets() how it will function?
under stand the web.php but others ??