Angular direct visit url routing

Angular direct visit url routing

239

If you ever worked with angular application and made it to production build you've probably noticed that direct url links will not work on your app for instance  https://example.com/category/angular  will return dead white screen instead of your actual page.

To solve that issue, what you need is to create .htaccess file in root of your angular application and add following codes into it, then save the file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*) /index.html [NC,L]

Now if you visit (i.e)  https://example.com/category/angular  you will see your data are loading.

- Last updated 2 years ago

Be the first to leave a comment.

You must login to leave a comment