I'm building an Angular app. It is hosted with base a href as /hris
. So my base url to access the app will be domain.com/hris
. Further, I have 3 different apps of which one is called term
. So when I click on the term
link it goes to domain.com/hris/term.
When the user directly tries to access the link domain.com/hris/term
, it returns 404 with a message: HTTP Status 404 - /hris/term
.
I don't want 404 to occur. How to get this done?
What I have done so far:
I tried to create a .htaccess
file in the folder, where index.html
resides.(I built the Angular app using ng build --base-href=/hris/
). I deployed the dist
folder to the server in a directory called hris
.
In the .htaccess
file I used the following variants, to no avail.
1
<IfModule mod_rewrite.c>
Options Indexes FollowSymLinks
RewriteEngine On
RewriteBase /hris/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
</IfModule>
2
<IfModule mod_rewrite.c>
Options Indexes FollowSymLinks
RewriteEngine On
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
3
<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>
I am using Angular 5. Please let me know if my approach is right, or what I have to do to get this going.
Version: Apache Tomcat 7- Version 7.0.64