I am building an application with the help of Angular6 and facing problems in routing. All the routes are working when I click on a particu
Add .htaccess
file to your src
folder.
.htaccess file
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html
# to allow html5 state links
RewriteRule ^ index.html [L]
Load .htaccess
file in your build directory dist
by adding it to assets
in angular.json
"assets": [
"src/favicon.ico",
"src/assets",
"src/.htaccess"
],