i need tutorial or explain with code


May 6th, 2023 02:27 AM

i want when user register new account creat his own domain and user can direct his custom domain like www.userdomain.com to user.laravelproject.com

i need tutorial or explain with code



May 6th, 2023 05:29 PM

Hi, you can use the Route::domain function in Laravel.

You can find an example at https://github.com/spatie/spatie.be/blob/main/routes/web.php

You can find the documentation on Route::domain at https://laravel.com/docs/10.x/routing#route-group-subdomain-routing

Additionally, here is a code sample, written in Laravel 10.

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

If you feel like my answer has helped you, please mark it so others can find it!