I have two criteria I am trying to meet with my .htaccess file and I'm currently getting an infinite redirect loop. I need to:
- Ensure SSL (https) when visitors attempt to resolve to the http version of the site
- I'm using Angular and want to rewrite the URL
I can do these both independently as follows:
- .htaccess file for SSL
AddHandler application/x-httpd-php72 .php
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
- .htaccess file for url rewriting to work with angular
AddHandler application/x-httpd-php72 .php
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html [L]
Both of these work independently BUT do not work together (get the redirect loop I mentioned) with this attempted .htaccess file:
AddHandler application/x-httpd-php72 .php
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html [L]
I want to avoid the error ERR_TOO_MANY_REDIRECTS when I attempt to access the site - has anyone any advice on how I correct the above in my .htaccess file to stop the multiple redirect loop.
Thanks in advance for any help!