Skip to content

Instantly share code, notes, and snippets.

@loorlab
Created September 16, 2022 20:02
Show Gist options
  • Save loorlab/e006ad476c7be0dbac26a6ad14e140a1 to your computer and use it in GitHub Desktop.
Save loorlab/e006ad476c7be0dbac26a6ad14e140a1 to your computer and use it in GitHub Desktop.
.htaccess https and force non www WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://domain.com%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule (.*) https://domain.com%{REQUEST_URI} [L,R=301,NC]
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