I have an Angular 5 application and I need to redirect all the traffic to Https when it's not already the case. I only have access to .htaccess to do that.
At first, i had that configuration :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
Works fine to avoid 404 and let Angular handle the routing, but when i try to add https, it broke everything.
I've tried multiple things, first i tried to add :
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
But I got too many redirections and can't load the page
Then I tried to replace my conf with :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . https://%{SERVER_NAME}/index.html [L]
</IfModule>
All the URI are handled but they always redirect to "/" in Angular, so I can't use Url to navigate (for example I have a /admin section that can be accessed only by URL )
I'm not used to apache, I usually work with nginx, does somebody have an idea on how to fix my issue?
Thanks