normalize_uri fixes (double slashes and trailing slash)

This pull request fixes mainly two issues:

1. One of the intended behaviors for normalize_uri() is to eliminate all double slashes, but all it does it remove the first one.  So this pull request addresses the correct behavior.  I also added more comments to better explain what the function does.

2. Another problem is normalize_uri() removes the trailing slash, but sometimes that slash is actually needed. For example: if a module wants TARGETURI to be a directory, you should NOT strip the trailing slash.  If you do, you may end up getting a 301 or 404 instead of 200 (expected output).  This pull request only modifies those that need TARGETURI to be a directory.