Skip to content

Instantly share code, notes, and snippets.

@jonbrockett
Created January 15, 2019 20:20
Show Gist options
  • Save jonbrockett/d801ee58d672a5807459d9e97fe9f88c to your computer and use it in GitHub Desktop.
Save jonbrockett/d801ee58d672a5807459d9e97fe9f88c to your computer and use it in GitHub Desktop.
HTTP to HTTPS Redirect
# Force Redirect HTTP to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<-- Using URL Rewrite module as well as IIS 7 and higher only. -->
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
/** Force admin to use SSL */
define('FORCE_SSL_ADMIN', true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment