Hello,
You can use parse_url : http://php.net/manual/en/function.parse-url.php
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello! I'm a beginner and I'm trying to create my first website with Laravel. For each distributors, I stored an url (e.g in the table distributors I have the 'name'='CatenaPharmacy' and the url='www.catena.ro' . ) How can I get the ulr of distributors without my domain ? (I don't want http://mysite/catena , I want just www.catena.ro ).
You need to decide if you will store http:// or https:// with the domain name.
If you just put the domain name on the page;
<a href="{{ $distributor->url }}">{{ $distributor->name }}</a>
then the URL will be relative to your website, so the URL needs to start with http: or https:
You could do this like;
<a href="http://{{ $distributor->url }}">{{ $distributor->name }}</a>
but there are two problems with this.
Your url might need to be https not http
You might copy the URL straight into your database and it may already start http:// - now you have added it twice.
Best option is to ensure when the URL is added to the database it includes the http or https in the first place.
Please or to participate in this conversation.