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]
Comments
- Anonymous
June 26, 2017
Thanks for adding this documentation.Where do I put .htaccess? Is it /home/site/wwwroot/?- Anonymous
June 26, 2017
yes
- Anonymous
- Anonymous
June 27, 2017
The comment has been removed - Anonymous
September 20, 2017
How can i put a file in wwwroot when deploying from azure container registry?- Anonymous
September 25, 2017
If you are using custom container, you can change it while creating DockerFile..
- Anonymous
- Anonymous
November 13, 2017
This doesn't work. I am running a node application.