mrperfectionist's avatar

Dynamic URL in Laravel

I have a link, which value is coming from database. Like this:

<a href="{{ url($facebook)}}">Link</a>

But it is creating the URL like this

http://localhost:8000/amazon.com/xyz

I don't want localhost:8000. What is the approach? Just it will be: amazon.com/xyz

0 likes
3 replies
Snapey's avatar

Because if you don't specify the protocol then it will assume the link is local

prefix it with https:

<a href="https://{{ url($facebook)}}">Link</a>

Of course it might not be https....

rawilk's avatar
rawilk
Best Answer
Level 47

Don't use the url helper for external urls. All you need is //: <href="//{{ $facebook }}".

1 like

Please or to participate in this conversation.