So I've created this function that get's the URL of the Website, but I also want it to remove the trailing /
as well.
So far I have this:
function base_url() {
$base_url = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
return $base_url.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
But I don't know how to remove the trailing /
from the URL.
I've also tried to add the rtrim
but still no luck:
function base_url() {
$base_url = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
$base_url = rtrim($base_url, '/');
return $base_url.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
Image of the URL -