The alias method you mentioned may be a bit cumbersome, because there
could potentially be several hundred users. So now I have the following
rules in place:
RewriteRule ^/$ /usr/local/apache/htdocs/index.html [L]
RewriteRule /(.*)/?(.*) /home/$1/$2
Which basically makes the index.html file appear if they go to the root
directory. Every other request is treated as a home directory (which is
the main purpose of the server). However, isn't there an RE that I can
set up that would be a little bit more intelligent? For example, if
there was a . after the first / (but before any second /) in the URL, it
would get directed to the appropriate page in the home directory. If
there was no period (since user names won't contain periods), it gets
treated as a user's home directory? For example:
http://server/index.html is at /usr/local/apache/htdocs/index.html
http://server/graphic.gif is at /usr/local/apache/htdocs/graphic.gif
but
http://server/jsmith is located at /home/jsmith/index.html
http://server/jdoe/page.html is located at /home/jdoe/page.html
I'm a little rusty on my RE's, but there should be a way to search for a
period between the / marks.
--Ethan
> > I am setting up a server, and I want users to be able to access their
> > home directories as
> > http://server/username
> > instead of the "standard"
> > http://server/~username
> > What is the easiest way to do this? I thought I could do it using
> > UserDir, but it seems that it automatically assumes ~user. Now I'm
> > thinking mod_rewrite might be a better choice, but I'm not famailar with
> > how to do it.
> First, you need to be a little more specific.
> Do you need to serve content other than userdirectories? (In other
> words, do you want to serve anything out of the document root?)
> If no, just use something like
> AliasMatch /(.*)/?(.*) /home/$1/public_html/$2
> or
> RewriteRule /(.*)/?(.*) /home/$1/public_html/$2
> (completely untested, of course)
> If yes, you need some way for the server to differentiate between
> requests which should be served out of the document root, and requests
> which should be served out of the user directories. One method is
> to enumerate all the user directories, and setup an alias for each, as
> in
> Alias /ethan /home/ethan/public_html
> If you have lots of them, you could use an external map file and have
> mod_rewrite look up the appropriate directory.
> --
> Joshua Slive
> http://finance.commerce.ubc.ca/~slive/
--
-----------------------------------------
Lehigh University
Computer Engineering Major, Class of 1999
http://www.lehigh.edu/~ecb2