How to set php artisan serve with custom domain in Laravel on Windows

Last updated at April 25, 2021

💬

php artisan serve command runs your website with 127.0.0.1 ip and 8000 port by default.

How can we serve with custom domain like zemna.test for development?

Before starrt

You can use any name of domain only for your computer. But the best practice is use .local or .test domain.

In past, .dev domain also be used many times.

But .dev domain will be automatically redirect to https protocol by browser.

So, use .local or .test domain.

Add custom domain mapping in Windows hosts file

Open C:\Windows\System32\drivers\etc file, and add a new line

C:\Windows\System32\drivers\etc
127.0.0.1 zemna.test

Upate app url in .env file

Update APP_URL in your .env file

/.env
APP_URL=http://zemna.test

Run php artisan serve command with custom domain

bash
php artisan serve --host=zemna.test --port=80

Access your web application using custom domain

You can access your web application with custom domain.