how to remove multiple slashes in URI with 'PREG' or 'HTACCESS'
snippet in htaccess

how to remove multiple slashes in URI with 'PREG' or 'HTACCESS'

user5767

   $url =  "site.com/edition/new///";

$newUrl = preg_replace('/(\/+)/','/',$url);

// now it should be replace with the correct single forward slash
echo $newUrl

how to remove multiple slashes in URI with 'PREG' or 'HTACCESS'

user7799

$url = 'http://www.abc.com/def/git//ss';
$url = preg_replace('/([^:])(\/{2,})/', '$1/', $url);
// output http://www.abc.com/def/git/ss

$url = 'https://www.abc.com/def/git//ss';
$url = preg_replace('/([^:])(\/{2,})/', '$1/', $url);
// output https://www.abc.com/def/git/ss