Deploy angular build in Apache

Normally Apache will through error,like when try to access http://localhost/login , apache will try to load folder called login.

To make this work , we can write rule in .htaccess as below

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

Make use you have enabled the rewire module in Apache.

And if you your using any folder in Apache like http://localhost/sub-folder/login, you have to specify the path while build the project as $ng build –base-href /sub-folder/

Advertisements