Skip to content

Instantly share code, notes, and snippets.

@SalmanRavoof
Created October 9, 2019 21:13
Show Gist options
  • Save SalmanRavoof/15c9a10ee86b52d2972a40cbb71a99ae to your computer and use it in GitHub Desktop.
Save SalmanRavoof/15c9a10ee86b52d2972a40cbb71a99ae to your computer and use it in GitHub Desktop.
Force any HTTP request to redirect to HTTPS by adding the first three lines to your WordPress .htaccess file. The next part is WordPress' way of handling Pretty Permalinks.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
# 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