Edit: Well, ###, it looks as if I was composing a very long reply even while you were deleting the material I was replying to. So now I'll have to go back and see what you ended up deciding to ask.
but not for
some/path/
That is very odd indeed. So let's look at what is
supposed to happen:
What's going on with the trailing slash?
If you put in a request for
/some/path
then mod_dir kicks in and issues a 301 redirect to
/some/path/
and then mod_dir again looks to see whether you have a DirectoryIndex line. 999 times out of 1000 this will be something like "index.html" or "index.php" referring to a file in the directory you're aiming for.
Those are the default behaviors for mod_dir. And at this point I need to double-check: Is this some type of shared hosting, or is it your own server?
The most likely way I can think of that a request for
/some/path/
with trailing slash would
not activate the htaccess located in this directory is if you have a non-standard DirectoryIndex such as
DirectoryIndex /some/otherpath/index.php
Then a request for URL /some/path/ would end up being a request for a file located in /some/otherpath/ possibly subject to a different htaccess.
If it's your own server, there are other possible explanations involving mod_alias. But there's still the question of why /some/path would behave differently from /some/path/ since by default the first form redirects to the second ...
unless you've set
DirectorySlash off
This can be done in htaccess, but I can't imagine a host ever doing it by default for the whole site. See
Apache docs [httpd.apache.org] for dire warnings. Short version: auto-indexing works with or without the trailing slash-- assuming you've enabled it-- but DirectoryIndex (using a physical file) only works
with the trailing slash.
That's why it becomes necessary to know whose server it is.
:: detour here to read up on FallbackResource which I could swear I've never heard of in my life, but there it is in 2.2, with further detour to query confusing wording ::
And now for the revised reply to the revised post: I read somewhere that a rule like "RewriteRule . new_url" will rewrite all URLs, but that doesn't work if it resides in /some/path/.htaccess and the URL ends with /some/path/ i.e. ends with a slash.
It shouldn't make any difference unless you've got a weird DirectoryIndex line. No, wait, there's one more exception. I've never found this spelled out in the docs, but I noticed it in the course of playing around on my test site:
When a RewriteRule ends in some kind of [R] flag, the "pattern" seems to apply only to the visible URL. When it ends in an [L] flag alone, the pattern may also apply to internal requests -- such as /index.html in a directory. So a request for some directory, ending in / slash, either
will or
will not trigger a rule whose pattern ends in "html":
/path/morepath/
may or may not be interpreted as
/path/morepath/index.html
depending on flag. Hence the difference between .* and .+
Again, I'm describing what I've personally seen in action, not what I've found in docs.
RewriteRule ^my\.domain/my/path/(.+) etc
Oh, right, you
are the one with his own server. I have to remember that: It's significant in mod_rewrite because in per-directory context (including htaccess) the domain name would never be part of the pattern.
Should I perhaps have a rule that removes it, in case there is nothing after it?
No, certainly not, or mod_dir will go insane. But I think I did end up answering the question, even if you reworded the whole thing while I was typing :)
When choosing between .+ and .* you should think about which forms can actually occur, and under what circumstances. For example: a rule meant to cover anything and everything in a particular directory, such as a global redirect, is generally
/directory/.*
But say you're looking for anything with html extension. You wouldn't say
.*\.html
because if someone is putting in a request for "example.com/.html" there's no point in humoring them even for a moment.