Reputation: 471
I have an application built with Angular Cli. I can open the default view without a problem but when I try to access another part of the page I get the following error message:
Not Found
The requested URL /myapp/calendar/2017-11-04 was not found on this server.
Apache/2.4.18 (Win64) PHP/5.6.19 Server at localhost Port 8099
The route for calendar is defined like this:
{path: 'calendar/:id', component: CalendarComponent},
I do not know if this is a problem my angular app or if it is a problem with Wamp server. Any suggestions on where I should start looking?
Upvotes: 0
Views: 561
Reputation: 559
You need to add an URL Rewrite rule on the server corresponding to the <base href="/myapp/">
value in index.html
to make the server ignore the routes handled by the Angular router. So the server returns index.html
for those routes, which in turn will bootstrap the app and take care of the route. You can read about that subject at Routing helper: MapSpaFallbackRoute
Something like (acually this RegEx is wrong. You need to ignore files with extensions, like script names.)
RewriteRule ^myapp\/.+ myapp/index.html
I am not an expert in Wamp, so you can read the following tutorial How to make mod_rewrite work on wamp
Upvotes: 1