Angular direct visit url routing

Angular direct visit url routing

17

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 1 month ago

Be the first to leave a comment.

You must login to leave a comment