I'm currently learning Angular-CLI for a Project. I succeeded in creating a simple little project with some routing Objects. In dev mode with ng serve, everthing works just fine. I can call the localhost:port in the browser and it works with the routing.
.
After a successful ng build -prod and moving all the stuff from the dist directory into my Server Folder (Apache24/htdocs), I start my Server and the main Side (mywebside) just works fine, the routing however does not... (i.e. localhost/about), instead I get a standart Error-Page as shown below:
Hope I was able to describe clearly what I did and where my problems are. I didn't posted any Code because I think the problem has to be else where.
Thank you for your help!
Manuel
angular CLI: Beta.8 (latest)
(apache): 2.4.20
OK figured it out (with help from PierreDuc!)
You have to do 2 things:
ErrorDocument 404 /index.html
(you find the File in the Apache24/conf/ directory) search for the line:
<Directory "c:/Apache24/htdocs"> [...]
-> in my Version of apache it is in line 244
a few lines further (after a few comments) you should find this line:
AllowOverride none
-> in my Version of apache it is in line 264
change this line to
AllowOverride ALL
Thats it, now your Angular-CLI Website should work in the production build with routing objects
hope it might be helpful to other Developpers!
Thanks to PierreDuc!
Manuel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With