I\'ve looked around the web for this before, and I suspect the answer is \"you can\'t\", but since I\'ve not yet found an answer which is that definitive, I think it\'s wort
No.
The problem is not so much related to the director/file mapping (which has never been expected as how mappings would happen, only allowed as a convenient mapping, which still often are convenient).
It's more related to the simple fact that dolor
is not the same as dolor/
and you want to give a new URI from a reference relative to dolor/
when combined to one ending in dolor
.
What may be the solution, is to act with /lorem/ipsum/dolor/
all the time. That is to say, never talking about /lorem/ipsum/dolor
at all, only ever about /lorem/ipsum/dolor/
. After all, since the directory/file mapping is, as you say, not the only way to do things, there's no reason why your resource names shouldn't always end in slashes.
Indeed, this may make more sense anyway, as in using such relative links you are implying that there is some sort of relationship between /lorem/ipsum/dolor/not-dolor
and /lorem/ipsum/dolor
. Now, while /lorem/ipsum/dolor/not-dolor
may not have much of a relationship to /lorem/ipsum/dolor/
, the implication that it might is there in the URI (yes URIs are opaque, but also while they must be treated as opaque at some levels, they are allowed to reflect relationships, and this is precisely why relative URI references make sense). Arguably therefore, /lorem/ipsum/dolor/
more clearly reflects your overall URI-to-resource mapping (if it didn't, you wouldn't want to be going from dolor to not-dolor anyway).
Now, this comes down to redirecting to a trailing slash, which you say you want to avoid (or better yet, never leading someone to dolor
in the first place), but its advantages now seem better than just the convenience of easier relative URIs.