Skip to content

Instantly share code, notes, and snippets.

@SalmanRavoof
Created October 9, 2019 21:14
Show Gist options
  • Save SalmanRavoof/d8400b3122c4ad1c83675ade264d6432 to your computer and use it in GitHub Desktop.
Save SalmanRavoof/d8400b3122c4ad1c83675ade264d6432 to your computer and use it in GitHub Desktop.
Alternative way to force any HTTP request to redirect to HTTPS by adding the first three lines to your WordPress .htaccess file. The next bit is WordPress' way of handling Pretty Permalinks.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L,NE]
# Please make sure to replace the example.com domain name in line 3 with your own
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment