Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refreshin angular build shows 404 Not Found Error on Apache Server

Tags:

angular

I am creating ng build --prod in angular 6, and deploying it to the Apache Server. Build works fine but when iam refreshing the page it shows "Not Found". Also iam creating .htaccess file in my root folder...

RewriteEngine On  

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]  
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d  
RewriteRule ^ - [L]


RewriteRule ^ /index.html  
like image 831
fahad ali Avatar asked Feb 14 '26 12:02

fahad ali


1 Answers

One of the possible reason could be that you are deploying in a sub-directory.

Change this line

RewriteRule ^ /index.html  

to

RewriteRule ^ /subDirectoryName/index.html  

Hope this helps.

like image 125
Faheem Avatar answered Feb 17 '26 03:02

Faheem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!