It's a very common bug actually. When you use php_explode() for the REQUEST_URL for a case like '/webmasters/tools/submit-url' the array returned has a structure like array([0] => '', [1] => 'webmasters', [2] => 'tools', [3] => 'submit-url')
Whereas in case of REQUEST_URL like '/webmasters/tools/submit-url/' the array returned has a structure like array([0] => '', [1] => 'webmasters', [2] => 'tools', [3] => 'submit-url', [4] => '')
So, in the case with an extra '/' the length of aruguments increases and also the last argument becomes ''. Usually this is handled by busting the empty last and first array indexes.
Thats why better to make your own function to decode urls when using them with .htaccess ;)
Question!I always assumed a URL is same with or without the ending / (forward slash). How can they behave differently?
The server just receives the URL from the client as a string; there's nothing in the protocol that requires a trailing slash to be ignored. Consider:
if (REQUEST_URL == "/something") send_something()
if (REQUEST_URL == "/something/") send_something_else()
Many web servers, such as Apache, helpfully adds a missing slash if it detects that the URL you're trying to access actually maps to a directory in the file system.