server { listen 80; server_name your_domain.com; root /var/www; # Main location block location / { try_files $uri $uri/ =404; } # User directories location ~ ^/~(.+?)(/.*)?$ { alias /var/www/$1$2; autoindex on; index index.html; try_files $uri $uri/ /~$1/index.html; } error_page 404 /404.html; location = /404.html { internal; } }