Join WhatsApp ChannelJoin Now

Laravel 10 Get HTTP Hostname

Hi dev,

Today, i show you laravel 10 get HTTP hostname. This article will give you simple example of laravel 10 get HTTP hostname. you will laravel 10 get HTTP hostname. In this article, we will implement a laravel 10 get HTTP hostname.

you can use this example with laravel 6, laravel 7, laravel 8, laravel 9 and laravel 10 version.

You can easily get domain name or subdomain name. Request provides two methods to get the hostname as getHttpHost() and getHost().

So, let’s follow few steps to create example of laravel 10 get HTTP hostname.

Install Laravel

Follow This Command And Install Laravel

composer create-project laravel/laravel example-register

Example: 1

$host = request()->getHttpHost();

Example: 2

$host = request()->getHost();

Example: 3

public function yourControllerFun(Request $request) {
    $hostname = $request->getHttpHost();

    dd($hostname );
}

I hope it will assist you…

Recommended Posts