I have written a preg_match
code to remove all trailing slashes and that is as follows..
preg_replace("/(\/?)+$/",'',$_SERVER['REQUEST_URI']);
will this hold good any time.
what is the alternatives to remove all trailing slashes...
consider that the users would give sitename.com/folder/ or s开发者_开发问答itename.com/folder// or sitename.com/folder
You can do:
$path = rtrim($path','/');
See bellow:
<?php
$url = "http://example.co/4569128/removing-all-trailing-slashes-in-an-url/"
$newUrl = rtrim($url','/');
?>
Output : http://example.co/4569128/removing-all-trailing-slashes-in-an-url
------------------------------------------------------------------------
精彩评论