Skip to content

Instantly share code, notes, and snippets.

@ewingson
Last active December 16, 2018 15:23
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 ewingson/0991a7b8f6700e89b972f5c0a1cdf91d to your computer and use it in GitHub Desktop.
Save ewingson/0991a7b8f6700e89b972f5c0a1cdf91d to your computer and use it in GitHub Desktop.
apache2.conf_rewrite_engine_force_nonwww_https_piece_of_code_in_production
Rewrite Engine On
#RewriteCond %{SERVER_PORT} !^8443$ [OR]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
#removed port from rule
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment