Microsoft Azure Open Source Development Support Team Blog

Support for Open Source Technologies on Microsoft Azure App Service

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

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.

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]


Skip to main content

Join the conversation

Add Comment