Redirect HTTP to HTTPS from .htaccess for Azure Web App on Linux on Apache

less than 1 minute read | By Yi Wang

  1. To verify the request is sent from HTTP or HTTPS for Web App on Linux:

    Unlike the application running on Web App on Windows, the server variable “HTTPS” is not defined for Web App on Linux. Check for “X-ARR-SSL”, this variable is set if the request is HTTPS.

    This information may be verified from Apache server variables, but not showing from header in Fiddler.

  2. Implement rewrite rule in .htaccess to allow HTTP to HTTPS redirect:

    Instead of using system variable “HTTPS”, modify the RewriteCond to use “HTTP:X-ARR-SSL”, sample code in .htaccess:

     RewriteEngine On
     RewriteCond %{HTTP:X-ARR-SSL} ^$
     RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]