How to get site url in laravel?

Get Site url Using URL Helper

in laravel, there are various way to get site url.

File name : index.php


Syntax:-

url('/')
Example :-

echo url('/');
or

{{ url('/') }}

Get Site url Using URL Facade

File name : index.php

Syntax:-
URL::to("/")


Example:-
$url = URL::to("/");
print_r($url);

get current URL with parameters

How to get current URL without query string in Laravel

return \URL::current();


OR


return \Request::url();

How to get current URL with query string in Laravel

return \Request::fullUrl();

How to get url parameters in Laravel

get your url segment in Laravel by using segment method

$url_segment = \Request::segment(3);

Get the current URL without the query string

File name : index.php

$currentURL = url()->current();
dd($currentURL);

Get the current URL with the query string

File name : index.php

$currentURL = url()->full();
dd($currentURL);

Get the full URL for the previous request

File name : index.php

$preURL = url()->previous();
dd($preURL);

Get the current URL Without Query String

File name : index.php

$currentURL = $request->url();
dd($currentURL);

Get the current URL With Query String

File name : index.php

$currentURL = $request->fullUrl();
dd($currentURL);

Get Only Parameters Using segment

File name : index.php


//http://www.itechxpert.in/one/two?key=value
$currentURL = $request->segment(3);
dd($currentURL);

Get current url in blade view

File name : index.php

Path: {{ Request::path() }}



Url: {{ Request::url() }}



FullUrl: {{ Request::fullUrl() }}






Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here


Ittutorial