This posts follows on my tutorial “How to deploy a Django application on Uberspace”. To deploy a static web page, like an Angular project is very easy.

Steps

Setup your project

This is an example for a Angular project, where you can build you static page with the cli.

1
ng build --prod --output-path ./dist

Routing with .htaccess

Because you want that Angular handles the routes, you have to tell the webserver to route every request to the index.html, where your Angular project lives. You can do this by creating a .htaccess file in your DocumentRoot.

1
2
cd ~/html
nano .htaccess

Then paste this text. The last line adds optionally compression.

1
2
3
4
5
6
7
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript text/javascript application/json

For more information, visit the Uberspace manual