If your WordPress website’s canonical URL includes both http://
and https://
, it indicates a misconfiguration in the website’s settings or a plugin/theme conflict. This issue can negatively affect SEO and user experience. Here’s how to diagnose and fix it:
Why Does This Happen?
- Incorrect Site URL Settings:
- The
WordPress Address (URL)
orSite Address (URL)
fields in your WordPress settings might be misconfigured. - Example: If you accidentally set it as
http://https://example.com
, the canonical URL will reflect that.
- The
- Mixed Content or HTTPS/HTTP Redirection Issue:
- Conflicts between
http://
andhttps://
caused by plugins (e.g., caching, SEO, or SSL plugins). - An improperly configured SSL or redirection setup can lead to this issue.
- Conflicts between
- Theme or Plugin Canonical Tag Misconfiguration:
- The theme or an SEO plugin (like Yoast SEO or Rank Math) might be generating the canonical tag incorrectly.
- Database Corruption:
- If the URL values in the database (
wp_options
table) are corrupted or incorrectly set, this can cause the problem.
- If the URL values in the database (
- Hardcoded URLs:
- A hardcoded canonical URL in the theme or plugin files might be causing the duplication.
Steps to Fix the Issue
1. Check and Correct WordPress URL Settings
- Go to Settings → General in the WordPress dashboard.
- Ensure both fields are correct:
- WordPress Address (URL):
https://example.com
- Site Address (URL):
https://example.com
- WordPress Address (URL):
- Remove any extra
http://
orhttps://
prefixes.Tip: Always usehttps://
if your site is secured with SSL.
2. Clear Cache
If caching is enabled:
- Clear your website cache using caching plugins like WP Rocket, W3 Total Cache, or LiteSpeed Cache.
- Clear your browser cache as well.
3. Check SEO Plugin Settings
If you’re using an SEO plugin (e.g., Yoast SEO, Rank Math, or All in One SEO Pack):
- Navigate to the SEO plugin settings.
- Look for the canonical URL configuration:
- Make sure it’s set to use the correct URL (
https://example.com
). - Remove any manually entered
http://https://
values.
- Make sure it’s set to use the correct URL (
- Save changes and recheck the canonical URL.
4. Check for SSL Plugin Configuration
If you’re using an SSL plugin like Really Simple SSL:
- Check its settings and ensure there are no conflicting redirect rules or mixed content warnings.
- Re-run the SSL setup wizard to correct any issues.
5. Test for Plugin Conflicts
- Deactivate all plugins temporarily.
- Check the canonical URL to see if the issue is resolved.
- Reactivate plugins one by one to identify the plugin causing the issue.
6. Check and Update Theme Files
- If the issue persists, your theme might have hardcoded canonical URLs:
- Go to Appearance → Theme Editor.
- Check
header.php
or similar files for hardcoded canonical tags like:<link rel="canonical" href="http://https://example.com">
1 - Replace it with:phpCopy code
<link rel="canonical" href="<?php echo esc_url(home_url('/')); ?>">
- Save the changes.
7. Correct the Database Entries
If the issue is in the database:
- Use phpMyAdmin or a database management plugin (like WP-Optimize) to inspect the
wp_options
table. - Look for
siteurl
andhome
options. - Ensure their values are correct (
https://example.com
) and free ofhttp://https://
.SQL Query to check:sqlCopy codeSELECT option_name, option_value FROM wp_options WHERE option_name IN ('siteurl', 'home');
SQL Query to update:sqlCopy codeUPDATE wp_options SET option_value = 'https://example.com' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'https://example.com' WHERE option_name = 'home';
8. Verify Redirection Rules
- Check your
.htaccess
file (for Apache servers) or Nginx configuration for conflicting rules:- Example
.htaccess
for HTTPS:apacheCopy code<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule>
- Ensure there are no
http://https://
references in the rules.
- Example
- Test your site after updating
.htaccess
or restarting the web server for Nginx.
9. Check for Mixed Content Errors
Use browser developer tools to identify if there are mixed content issues or resources (CSS/JS/images) still being loaded over http://
.
Fix these by:
- Using relative URLs or ensuring all resources use
https://
. - Updating URLs in the database with a search-and-replace plugin (e.g., Better Search Replace).
Final Step: Test the Fix
- Use tools like Google Search Console or Screaming Frog SEO Spider to confirm the canonical tag is correct.
- Re-scan your site to ensure no
http://https://
URLs remain.