I\'m doing some url rewriting in PHP and need to find URLS with a slash at the end and then do a 301 redirect. I thought there\'d be a simple PHP function to find last stri
A nice solution to remove safely the last / is to use
/
$string = rtrim($string, '/');
rtrim() removes all /s on the right side of the string when there is one or more.
You can also safely add exactly one single / at the end of an URL:
$string = rtrim($string, '/').'/';