All of our Azure hosted WordPress (WP) websites use enforced HTTPS via the web.config file (Read how to do that here) so that all public access is via https, Within the WordPress Admin dashboard General Settings however, the WordPress Address (URL) and Site Address (URL) are still listed as http and the option to change this is grayed out:
How to fix this so that only https addresses are being used? The solution is done in the wp-config.php file accessed in an Azure hosted WP site, via the Kudu UI. (Read about how to use Kudu here.)
Solution 1:
- First step is ALWAYS to download a copy of the unedited wp-config.php file as a backup that can quickly be uploaded again if necessary. Mistakes happen – especially when you’re not prepared with a backup!
- Portal > Web App > Development Tools > Advanced Tools blade > Go > Debug Console > cmd > site > wwwroot > wp-config > edit > scroll down //Relative URLS for swapping across app service deployment slots
- Delete the first 2 lines that are hard-coding the relative WP and Site Addresses as http > Save
NOTE: The Azure App Service has added the ‘. filter_input(INPUT_SERVER, ‘HTTP_HOST’, FILTER_SANITIZE_STRING’ code because of the ability to create dev, test and prod staging slots. These are not necessary, if you aren’t using this functionality for your WP sites.
- You will be forced to login again to the Admin pages, but now you will see that the WP and Site Address options can be edited and Saved. Change both addresses to https > Save. Confirm the changes by navigating to the Settings > Permalinks page to see that all the listed addresses are now https:
Solution 2:
- When the 2 lines were deleted from the wp-config.php site in another site, a new address was added to the domain, and the we got the following error. And we were locked out of both the Public access and WP Admin sides of the site! Thankfully, we could fix what we needed to in Kudu UI!
- We pasted the 2 lines previously deleted back into the wp-config.php file and added the https absolute URL to both the WP_HOME and WP_SITEURL > Saved
- The public website and Admin sites were again accessible!
However, because the addresses are again hard-coded, the WP Admin General Settings has the grayed out Adresses showing again – but they are the https addresses this time!