When a request comes to my website from insecure http://, i want it to get redirected to https://.
My root directory has both html and php files in it. Based on request path i will decide whether to serve HTML or PHP file.
Below is my existing .htaccess file.
RewriteEngine On
RewriteRule "^(news_[^.]+|faq|terms|get).*" "$1.php" [NC,L]
the above configuration works fine for serving files from both secure and insecure domains.
But when i try to force SSL by changing the above configuration
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
# # Redirect to https version
RewriteRule ^get$ "https://example.com/get.php" [L]
RewriteRule ^faq$ "https://example.com/faq.php" [L]
RewriteRule ^terms$ "https://example.com/terms.php" [L]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
It is forcing SSL for all the html pages that is being served from the directory. But the /get, /faq , /terms are getting a request timeout.
How do i fix it ? Where am i doing it wrong ?