Skip to content

Instantly share code, notes, and snippets.

@gladx
Created October 18, 2020 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gladx/884ab4b2cdcd24e64d97098a072851b8 to your computer and use it in GitHub Desktop.
Save gladx/884ab4b2cdcd24e64d97098a072851b8 to your computer and use it in GitHub Desktop.
.htaccess with redirect to https
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment