Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Please have a look at the edit I just made to the OP. Commented May 6, 2019 at 21:32
  • OK. Your approach works. But why do you think that I should allow Apache to return a 404 here? The result of your code is that now the Angular 7 app running in the browser is able to return its own 404 page for every route after mydomain.com that is not defined in the Angular app. This allows separation of concerns, so that the Angular app can manage all the routes not specified on the server. What is wrong with this? Commented May 6, 2019 at 21:40
  • Your RedirectMatch simply doesn't catch all the paths you want. You could modify it and add lots of exceptions for every file you add somewhere to your DocumentRoot. But I don't think this is a good idea. The solution above rewrites all URI paths to /index.html which are not found in your DocumentRoot. If your app only needs files inside the DocumentRoot and has no other rewriting or proxying, then this could work for you. Commented May 6, 2019 at 21:40
  • I said if you want your config "as clean as possible"... What's wrong with a "page not found" if the page is not found? Sorry, I have no idea how your Angular app works. Commented May 6, 2019 at 21:49
  • For one thing, the approach desired in the OP and given in your answer isolates all the views in the browser app, so that the server can focus on serving a complete app instead of having the server try to be a UI app in addition to simply being a server. Thank you and +1 for answering the question in the OP. Commented May 6, 2019 at 21:53