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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s