Skip to content

Instantly share code, notes, and snippets.

@Maximization
Created July 27, 2020 15:31
Show Gist options
  • Save Maximization/fd1745fe21dda13bcbbc620ec195291d to your computer and use it in GitHub Desktop.
Save Maximization/fd1745fe21dda13bcbbc620ec195291d to your computer and use it in GitHub Desktop.
Redirect to non-www and https in one step with Apache
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) https://example.com/$1 [L,R=301]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment