So, rewrite rules actually operate on directory paths, so it seems that when converting the URL path to a directory path, Apache collapses the multiple slashes, which is why the rewrite rule can’t detect them.
You’ll have have to switch to checking %{THE_REQUEST} in a rewrite condition. THE_REQUEST is the full HTTP request line sent by the browser to the server (e.g., “GET /index.html HTTP/1.1”).
The quotes and the spaces in the condition are meant to be there. The quotes make the spaces be part of the matching pattern, and the spaces are part of the request line and delimit the URI.
The request URI will always include the initial slash of the path, so that’s meant to be there too.
The rewrite rule pattern is written so that it will always match anything. That’s because all the real work is being done in the condition.
Be back in a bit for the second half of your question.
Thanks for working with me on this. I am still encountering errors.
I tried what you posted and firefox told me that the request is being redirected in a way that will never complete. I’m at a loss here; my htacess file is exactly as you posted. Maybe the regex is re-capturing the request each time? I am attempting to go to http://localhost/test-site/one/ .
Ahh. Locked in an epic battle with Apache’s mod_dir. When the path maps to a real directory, then mod_dir will send a redirect with a trailing slash. But then whenever we get a request with a trailing slash, we send a redirect with the slash removed. Then mod_dir adds it. Then we remove it. So on and so on.
Which of the two would you prefer win? We could disable the mod_dir module, or we could restrict slash-removal to only non-real paths.
If I understand you correctly, is this a choice between having “example.com” and “example.com/” (with the / slash)? If so, I’d like non real paths like “example.com///” to redirect to “example.com/”. But, for paths under “example.com/” like “example.com/users” I’d like to omit the trailing slash. Although it would be nice to have it either way - example.com with or without a trailing slash.