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.

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]


Skip to main content

Join the conversation

Add Comment

  1. Thanks for adding this documentation.
    Where do I put .htaccess? Is it /home/site/wwwroot/?

  2. Hello. I followed the article and put .htaccess under /home/site/wwwroot/ using GitHub deployment. I restarted my app but accessing doesn’t redirect me to https. Am I missing a step?

  3. How can i put a file in wwwroot when deploying from azure container registry?

  4. This doesn’t work. I am running a node application.