Home/Article
Esadax JournalFAQ

How to Force HTTPS Using .htaccess in cPanel

To set up an HTTPS redirect for all instances of index.html across various subfolders, follow these steps: 1. Enable RewriteEngine: This is necessary for Apache to process rewrite rules. 2. Check

To set up an HTTPS redirect for all instances of index.html across various subfolders, follow these steps:

  1. Enable RewriteEngine: This is necessary for Apache to process rewrite rules.
  2. Check for Non-HTTPS Request: Ensure the request isn't already secure to avoid unnecessary redirects.
  3. Match Exact Filename: Use a condition to check if the requested file is exactly index.html.
  4. Redirect to HTTPS: Construct the redirect URL using the same host and URI, appending any subfolder paths captured by (.*).

Here's the complete rewrite rule:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_FILENAME} index\.html
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Subscribe