0

I removed # from my Angular application's url but I face a BIG problem... I followed many "solutions" but the result is the same..

My application "my-app" deployed on Apache2 (in subfolder) => /var/www/html/my-app

First access to the app (http://xxxxxx/my-app) => redirect to login page => OK Refresh page => ERROR 404 !!!

I added .htaccess files in public_html (ie /var/www/html) and sub-directory (ie /var/www/html/my-app) but still have the error...

Here .htaccess /var/www/html :

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
</IfModule>

And here .htaccess /var/www/html/my-app :

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /my-app/index.html [NC,L]
</IfModule>

Have any idea please to solve this problem ? Thank you !!

Mohamed
  • 2,342
  • 4
  • 21
  • 32

1 Answers1

0

Add below to your build file directory and from apache direcly point to this folder

   <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.html [L]
    </IfModule>

apache site

Shamith Wimukthi
  • 468
  • 3
  • 12