How can laravel arrange dynamic routing over subdomains for referral system? Those need for example with the user1.example.com subdomain to fix the ref when registering a user. The server itself on ubuntu + nginx and I can’t imagine how you can dynamically create the subdomains I need.
2 answers
1) In the DNS of your domain, make an A-record of the form * .site.com (thus all third-level domains will be sent to your server)
2) In the Laravel router list the rule
Route::domain('{account}.site.com')->group(function () { Route::get('user/{id}', function ($account, $id) { //здесь ваша функция }); }); |
Well, you need to write a config file like this
server { listen 80; server_name "~^(?<sub>.+)\.domain\.tld$"; root /path/to/document/root/; // .... конфиг для php ... // если нужно будет можно заюзать $sub - поддомен } Then you can, as with try files, pass this subdomain to request or to a variable environment, even give a hint, for example, to this APP_URL=$shema.$subdomain.youdomain.tld and operate them in laravel
|