WordPress Common Troubleshooting Scenarios
Mixed Content error on WordPress site
What does the mixed content error message indicate?
Normally when resources like images, CSS or JS files are requested with HTTPS and if they are loaded with HTTP protocol this can have an effect of mixed content error.
You can confirm if your site is being affected by mixed content errors by checking the browser inspect element console.
Error Message -
Mixed Content: The page URL was loaded over HTTPS but requested an insecure stylesheet.
Most browsers follow the RFC for Mixed Content, you can find information relevant on this restriction here: https://www.w3.org/TR/mixed-content/ and https://tools.ietf.org/html/rfc6797.
How to resolve the mixed content error?
- In the wp-config.php, please check if the below configurations like WP_HOME and WP_SITEURL settings are set properly as per your requirement. Please refer to the screenshot below for the recommended settings.
if (isset($_SERVER[‘HTTP_X_FORWARDED_PROTO’]) && $_SERVER[‘HTTP_X_FORWARDED_PROTO’] == ‘https’)
$_SERVER[‘HTTPS’] = ‘on’;
$http_protocol=’http://’;
if (!preg_match(“/^localhost(:[0-9])/”, $_SERVER[‘HTTP_HOST’]) && !preg_match(“/^127.0.0.1(:[0-9])/”, $_SERVER[‘HTTP_HOST’])) {
$http_protocol=’https://’;
} - In the Azure Portal, within the Custom Domains tab, check if the setting HTTPS only is turned on.
- Purge the Wordpress cache from the admin Dashboard.
-
If you’re still facing mixed content error search for HTTP references in the database and replace it with HTTPS. You can easily do it using the plugins below - Better Search and Replace or Search & Replace
- Please install the WordPress plugin ‘SSL Insecure Content Fixer’ and select the appropriate HTTPS detection method as in the screenshot below. For example,HTTP_X_ARR_SSL setting works for Azure Linux App Service blessed images.
How to Debug WordPress Errors
If your WordPress page is encountering application issues without any detailed errors, please use the below steps to debug further.
- Edit the wp-config.php file and look for the following line of code:
define(‘WP_DEBUG’, false);
Please update the line to the changes below -
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_LOG’, true);
define(‘WP_DEBUG_DISPLAY’, false);
@ini_set(‘display_errors’,0); - Check debug.log inside the wp-content folder and application logs for the detailed errors.
- Once you fix the issue please revert the changes done in step 1.
How to resolve the ‘Too Many Redirects’ issue encountered on your WordPress site
- Assess if the SSL, home_url and site_url configurations are set properly in your wp-config.php. Please refer to the screenshot and code below for the recommended settings.
if (isset($_SERVER[‘HTTP_X_FORWARDED_PROTO’]) && $_SERVER[‘HTTP_X_FORWARDED_PROTO’] == ‘https’)
$_SERVER[‘HTTPS’] = ‘on’;
$http_protocol=’http://’;
if (!preg_match(“/^localhost(:[0-9])/”, $_SERVER[‘HTTP_HOST’]) && !preg_match(“/^127.0.0.1(:[0-9])/”, $_SERVER[‘HTTP_HOST’])) {
$http_protocol=’https://’;
}
define(‘WP_HOME’, $http_protocol . $_SERVER[‘HTTP_HOST’]);
define(‘WP_SITEURL’, $http_protocol . $_SERVER[‘HTTP_HOST’]); - Disable all plugins by renaming the plugins folder to check if the redirection is being caused by any of the plugins. You can then re-enable them one by one to find the problematic plugin.
- Please check if the WordPress admin URL https://
/wp-admin or any other URLs within the admin page are also facing the 'too many redirects' issue. If only a few URLs are redirecting, it could be an incorrect redirect rule configured in the Redirect Plugins. Also, review the server configuration files like Nginx config files, .htaccess (in case you are using an Apache Web Server) or web. config (in case you are using the IIS Web Server) for any redirect rules that may have been configured and modify/update the configurations as needed.