我正在尝试/
从 URL 中删除最后一个,但前提是不存在目录。有没有办法检查if(3 slashes only && not https) remove slash
?还是有更好的方法来完成我想做的事情?
到目前为止我所拥有的
$url = preg_replace(array('{http://}', '{/$}'), '', $project->url);
当前输出:
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
我想得到什么
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/