1

I have created an angular 7 simple application with multiple routes

  • home
  • about
  • contact

I've deployed to a web server and when I go to my website https://www.example.com (defaults to home component) and click on the router link to take me to:

This works fine as it resolves to index.html and then javascript does the routing. However, when I attempt to load each of these pages directly I get a 404 not found (understandably as the web server cannot resolve the page).

My .htaccess file looks like this:

AddHandler application/x-httpd-php72 .php

What do I need to allow the web server to resolve my angular application in the expected way?

Thanks for any pointers in advance!!!

1 Answer 1

2

And almost as quick as I posted, I discovered this:

AddHandler application/x-httpd-php72 .php
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html [L]

Which worked for me!!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.