Created
February 27, 2018 00:01
-
-
Save nholman7/ece1db2e2352d3e1d94d83a9ba30b4e3 to your computer and use it in GitHub Desktop.
Custom Add HTTPS Canonical to HTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_canonical() { | |
if (isset($_SERVER['HTTP']) && $_SERVER['HTTP'] != 'off') { | |
return "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; | |
} else { | |
// Yoast SEO will use default canonical for HTTPS version site | |
} | |
} | |
add_filter( 'wpseo_canonical', 'custom_canonical' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment