Skip to content

Instantly share code, notes, and snippets.

@vital-tech-results
Last active July 9, 2022 23:22
Show Gist options
  • Save vital-tech-results/5d1a0f62b873be2ed118384ae0c3a4c1 to your computer and use it in GitHub Desktop.
Save vital-tech-results/5d1a0f62b873be2ed118384ae0c3a4c1 to your computer and use it in GitHub Desktop.
// source: https://www.namecheap.com/support/knowledgebase/article.aspx/9770/38/how-to-use-htaccess-to-redirect-to-https-in-cpanel // Redirect from http:// to https:// or https://www having CloudFlare Flexible SSL mode //a) Basic http:// to https:// redirection, but this block should be used along with CloudFlare Flexible SSL Mode
RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{HTTP_HOST} ^example\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteRule .* https://example.com%{REQUEST_URI} [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment