I am trying to remove the last /
from a URL, but only if there is no directory present. Is there a way to check if(3 slashes only && not https) remove slash
? Or is there a better way to accomplish what I am trying to do?
What I have so far
$url = preg_replace(array('{http://}', '{/$}'), '', $project->url);
Current outputs:
http://www.example.org/ => www.example.org
https://www.example.org/ => https://www.example.org
http://www.example.org/dir/ => www.example.org/dir
https://www.example.org/dir/ => https://www.example.org/dir
http://www.example.org/dir/dir/ => www.example.org/dir/dir
https://www.example.org/dir/dir/ => https://www.example.org/dir/dir
What I want to get
http://www.example.org/ => www.example.org
https://www.example.org/ => https://www.example.org
http://www.example.org/dir/ => www.example.org/dir/
https://www.example.org/dir/ => https://www.example.org/dir/
http://www.example.org/dir/dir/ => www.example.org/dir/dir/
https://www.example.org/dir/dir/ => https://www.example.org/dir/dir/