#Support UserDir (~/user/)
location ~^/~(?<userdir_user>.+?)(?<userdir_uri>/.*)?$ {
	alias /home/$userdir_user/public_html$userdir_uri;
	autoindex on;

	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		include /etc/nginx/fastcgi_params;
		fastcgi_index index.php;
	
		#try_files does not work after alias directive
		if (!-f $request_filename) {
			return 404;
		}

		fastcgi_param DOCUMENT_ROOT /home/$userdir_user/public_html;
		fastcgi_param SCRIPT_FILENAME $request_filename;
		fastcgi_pass unix:/usr/local/php54/sockets/$userdir_user.sock;
	}
}
