Laravel sub-domain cpanel

waqarhussain profile image Waqar Hussain ・1 min read

This guide describes how to configure a subdomain for laravel project.

Using example.com
if you own example.com and want to create subdoamin.example.com and handle it with laravel.
then follow these steps.

  1. Create a subdomain in cpanel and point its directory to the laravel project directory.
  2. now in your routes/web.php add this snippet.

Route::domain('subdoamin.example.com')->group(function () {
    //mobile routes
    Route::get('/', function(){
        dd("Reserved For subdoamin.example.com Site") ;

Now visit


and you will get

Reserved For subdoamin.example.com Site

I wrote the first time, and I am looking forward to hearing your opinion on how can I improve.



Editor guide