404 error on angular page reload. changes made to virtual host are not reflecting

Keywords: MEAN - AWS - How to - Other
Hi everyone.
I’m using Angular 7.2 in AWS lightsail MEAN. on page reload, angular page shows 404 error. I found the solution I need to add the below code in the virtual host
<Directory /path/to/app>
RewriteEngine on

    # Don't rewrite files or directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Rewrite everything else to index.html to allow HTML5 state links
    RewriteRule ^ index.html [L]

but its not working in bitnami apache. the same code is working in ubuntu apache

i followed this artical https://docs.bitnami.com/aws/infrastructure/mean/get-started/understand-config/ to edit my virtual host.
but the chages i make to virtual host is not refelecting.

my application works even if I comment servername in virtual host.
none of the changes i make to virtual host is refelecting.
i also checked vhosts folder there are no other virtual host configured

i just want to add few lines of code in virtual host.
any HELP will be appriciated

Hi @muzammil,

Thanks for using Bitnami. Could you tell us in what file did you do the changes?

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

Please note that you need to paste the code ID that is shown at the end.


hi @Ibone I ran the bitnami support tool and i got this code e514abd9-5de1-0fc1-92cd-6e055b28eb20
below is the code ID

When I run the command /opt/bitnami/ctlscript.sh status it says apache not running but my website is working fine. please let me know what to do. I just want to edit the right virtual host

Hi @muzammil,

In your logs the apache appears:

[Wed Nov 18 17:44:04.115773 2020] [authz_core:error] [pid 21902] [client] AH01630: client denied by server configuration: /opt/bitnami/apache/htdocs/.htaccess

Please check the content of that file.


Hi @Ibone Thank you for your reply I checked .htaccess if contains the below code

 RewriteEngine On
 RewriteCond %{SERVER_PORT} =80
 RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

when I run the command sudo /opt/bitnami/ctlscript.sh status it says
apache not running
mongodb not running
but my application is working fine. I dont have anyother webserver installed other than apache

Hi @muzammil,

To configure apache you can check this documentation https://docs.bitnami.com/bch/infrastructure/mean/administration/force-https-apache/

And for the .htaccess could you check this guide https://docs.bitnami.com/bch/infrastructure/mean/administration/use-htaccess/?

Could you run the following command?

sudo systemctl status apache2


hi @Ibone thank you for your reply
when I run the command sudo systemctl status apache2 it shows

Could you please tell me what is wrong

Hi @muzammil,

In your bnsupport appears this:

Running: ps aux | grep 'apache\|mysql\|nginx\|/opt/bitnami'
In: /opt/bitnami


root      1462  0.0  0.4 1303932 9824 ?        Ssl  Aug25   0:58 /opt/bitnami/gonit/bin/gonit
daemon   21895  0.0  0.4  14520  8908 ?        S    Nov18   0:14 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROU>
daemon   21896  0.0  0.4  14512  8912 ?        S    Nov18   0:15 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROU>
daemon   21902  0.0  0.4  14516  8876 ?        S    Nov18   0:14 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROU>
daemon   21918  0.0  0.4  14508  8860 ?        S    Nov18   0:15 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROU>
daemon   21919  0.0  0.4  14464  8824 ?        S    Nov18   0:17 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROU>
daemon   21965  0.0  0.4  14392  8904 ?        S    Nov18   0:12 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROU>
daemon   21972  0.0  0.4  14492  8884 ?        S    Nov18   0:14 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROU>
daemon   21973  0.0  0.4  14488  9000 ?        S    Nov18   0:15 /opt/bitnami/apache/bin/httpd -f /opt/bitnami/apache/conf/httpd.conf -D FOREGROU>
root     31958  0.0  0.1   9940  3712 pts/0    S+   10:28   0:00 sudo /opt/bitnami/bnsupport-tool
root     31959 13.8  8.2 204644 169080 pts/0   Sl+  10:28   0:12 /opt/bitnami/bnsupport-tool
root     32104  0.0  0.0   2388   764 pts/0    S+   10:30   0:00 /bin/sh -c "ps" aux | grep 'apache\|mysql\|nginx\|/opt/bitnami'
root     32106  0.0  0.0   6212   892 pts/0    S+   10:30   0:00 grep apache\|mysql\|nginx\|/opt/bitnami

You can see there an apache at the end,

let’s try these commands:

sudo systemctl disable apache2 
sudo systemctl stop apache2
sudo /opt/bitnami/ctlscript.sh stop apache
sudo /opt/bitnami/ctlscript.sh start apache

I hope that helps you,

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.