Using getSchemeAndHttpHost method
<?php // get url using "getSchemeAndHttpHost" request()->getSchemeAndHttpHost();
Using url() Helper Method
You can also use the "url()" helper function method
<?php // get the base url using the "url" helper url(''); url('/');
Using config Helper method
You can make use of the "config()" helper method as well.
<?php // get the url from the "app.url" config('app.url');
Other: Accessing Current URL
There are other helper methods as well to get the "current" URL of a page and you can write your code as follows
// Get the current page URL without the query string echo url()->current(); // Get the current page URL including the query string echo url()->full(); // Get the full page URL for the previous page echo url()->previous();
Leave a reply