server { listen 80; server_name example.com; location ~ ^/~(.+?)(/.*)?$ { alias /home/$1/html$2; index index.html; autoindex on; } }