I am developing a Laravel application in which I have simple urls like -domain.com/shop but I want to create two dynamic urls for this like:
Both dynamically point to the same url. I want to dynamically define a subdomain url and a simple url pointing to the same page for each user.
P粉5534287802023-09-16 14:34:54
After a lot of research and trying different methods, I finally solved this problem.
After using Acrylic DNS proxy, I have to use two different roots for the main domain and subdomain.
This is the main domain:
// Match my own domain Route::group(['domain' => 'tc.dev'], function() { Route::any('/', function() { return 'My own domain'; }); });
Another one for handling subdomains:
Route::group(['domain' => '{subdomain}.tc.dev'], function() { Route::any('/', function($subdomain) { return 'Subdomain ' . $subdomain; }); });
In fact, the main thing is that I have to use another route to control the route that acts on the main domain, and I am ignored.