You could enable per-user web directories with mod_userdir which maps
http://example.com/~username/index.html
to the corresponding file
/home/username/public_html/index.html
in the user directory per default.
To get rid of the tilde, you could use Apache's rewrite engine and forbid access to all URLs starting with ~
and use Alias
es to map the individual paths to their user directories.
Add this to your VirtualHost config:
RewriteEngine On
# forbid URLs starting with /~
RewriteRule ^/~ - [F]
# map individual paths to user dirs
Alias /bart /home/bart/public_html
Alias /homer /home/homer/public_html
Alias /lisa /home/lisa/public_html
Alias /maggie /home/maggie/public_html
# ...
If you don't need to serve any files from your DocumentRoot
, you could use one AliasMatch
instead of 150 Alias
es:
# map all paths to user dirs
AliasMatch ^/([^/]+)(/.*)?$ /home/$1/public_html$2
You need to enable mod_userdir
and mod_rewrite
in your server, on Debian you would do this with a2enmod
and a restart.
sudo a2enmod userdir rewrite
sudo service apache2 restart
url
something likehttp://example.com
or something likehttp://example.com/path/to/userdirs
?url
is something likehttp://example.com/username/index/html
where username will vary for different users