(My apologies if this is in the wrong place or has already been asked.)
I've just set up an Apache webserver and am having headaches with UserDir and trailing slashes. The UserDir directive is just:
UserDir public_html
And it works for http://www.example.com/~user/
but not, as far as I can tell, for http://www.example.com/~user
. What seems to happen is that it gets sent to DocumentRoot/~user
which then eats it up (the stuff in DocumentRoot
has its own set of what-to-dos for files that don't exist, just in case that's important, so as far as Apache is concerned something does something with the request).
Is there a way to make http://www.example.com/~user
work via mod_userdir, or does it need another level of processing first? If so, what?
Edit: A little experimenting, and comparing with another system where it does work, led me to add the rule:
RedirectMatch /~user$ /~user/
to the .htaccess
in user/public_html
. So it looks as though the request http://www.example.com/~user
is getting passed to the user's directory, but then it doesn't find anything to match and so sends it back to the server saying "I can't find anything, take a look in DocumentRoot
.". So it seems to be a strange incantation of the "trailing slashes" issue. I had thought to fix trailing slashes with a bit of mod_rewrite
trickery, but I couldn't find a set of rules that would match /~user
. So the problem appears to be that the request http://www.example.com/~user
does not get matched to /home/user/public_html/index.html
whilst http://www.example.com/~user/
does.
Refined question: Is there a server configuration that will fix this match, or is the RedirectMatch
rule the simplest method?