Share via


HTTP to HTTPS redirect for WordPress on Azure Web App on Linux

If you host WordPress site on Azure Web App on Linux running Apache, here are the steps to implement HTTP to HTTPS redirect:

1. Add RewriteRule in .htaccess in WordPress application root

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

2. Once this RewriteRule is added, you may see wp-admin page lost style like this, this is caused by loading mixed content from http and https,

Here is a way to fix this, add following code in wp-config.php,

 define('FORCE_SSL_ADMIN', true); 
if ( isset($_SERVER['HTTP_X_ARR_SSL']) ) 
        $_SERVER['HTTPS']='on';

Comments

  • Anonymous
    August 19, 2017
    Spent so much time trying to figure this out... thank you so much.