I am using laravel 5 and I am trying to get my full url which is /faq#manual However I can only get /faq when I call the function Request::url() or Request::fullUrl() is there any way I can get the full url with #manual?
Asked
Active
Viewed 2,841 times
1
-
2Possible duplicate of [Get fullUrl in laravel 5.1](https://stackoverflow.com/questions/33687496/get-fullurl-in-laravel-5-1) – Kapitan Teemo Nov 07 '18 at 03:50
-
Request::fullUrl() will not return with a url fragment. If you want the fragment you will need to do that client side. – Adam Rodriguez Nov 07 '18 at 03:56
-
how can I get the full url with the # on the client side? I want to show it in my blade. can you help me? – R. cong Nov 07 '18 at 04:03
2 Answers
3
It is impossible to get the fragment from a URL with Standard HTTP. So using variables like $_SERVER or $_GET can't help you. Actually, the server never knows about this value because the browser won't even send a request with a fragment part.
If you want to have the fragment value in the server side, you should get the value by javascript first then pass it as a URL parameter and get it by $_GET in your server side.

Mahdi Jedari
- 712
- 1
- 7
- 16
1
That's not possible in http or php however you can use javascript to get the full url including the hash.
var url = document.URL;
or
var url = window.location.href;
Hope this helps.

Jesus Erwin Suarez
- 1,571
- 16
- 17