I am deploying an Angular 4 application on an EC2 instance. I compiled the application with ng build --prod and moved the contents of the dist directory to /var/www/html. Furthermore, I have started the web service daemon with sudo service httpd start. The webpage works except that I can only access routes via the main page.
For example I can get to:
http://my-page.com/dashboard
only by first visiting
http://my-page.com
and then clicking on the dashboard button. However, I cannot access this portion of the application directly by navigating to http://my-page.com/dachboard as was possible in the the angular development environment (Angular CLI server).
I would like to know if this is possible and how to achieve this. The steps that I have taken to try to resolve this are
- Enable
mod_proxyby addingRewriteEnging Onand addingProxyPass * http://my-page.com/andProxyPassReverse * http://my-page.com/to thehttpd.conffile - Try to add
AllowOverride Allto thehttpd.conffile - Configuring
.htaccessto allow RewiteEngine.