Title: Both HTTP and HTTPS canonical tags being generated.
Last modified: August 30, 2016

---

# Both HTTP and HTTPS canonical tags being generated.

 *  [zionsrogue](https://wordpress.org/support/users/zionsrogue/)
 * (@zionsrogue)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/both-http-and-https-canonical-tags-being-generated/)
 * I have a website running the WordPress SEO plugin. When I go to [http://www.example.com](http://www.example.com)
   and view my source I see:
 * `<link rel="canonical" href="http://www.example.com" />`
 * As my canonical tag.
 * And when I go to [https://www.example.com](https://www.example.com), I see:
 * `<link rel="canonical" href="https://www.example.com" />`
 * as the canonical tag (note the https vs. http)
 * How do I _force_ the canonical tag to be `<link rel="canonical" href="http://
   www.example.com" />` regardless of which protocol is used?
 * [https://wordpress.org/plugins/wordpress-seo/](https://wordpress.org/plugins/wordpress-seo/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Dax](https://wordpress.org/support/users/daxpod/)
 * (@daxpod)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/both-http-and-https-canonical-tags-being-generated/#post-6280969)
 * Love to solve this issue.
 *  Thread Starter [zionsrogue](https://wordpress.org/support/users/zionsrogue/)
 * (@zionsrogue)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/both-http-and-https-canonical-tags-being-generated/#post-6280970)
 * Yes, I totally agree Dax!
 * Could the Yoast SEO developers **_please acknowledge this issue_**and provide
   a fix for it?
 *  [swagzillionaire](https://wordpress.org/support/users/swagzillionaire/)
 * (@swagzillionaire)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/both-http-and-https-canonical-tags-being-generated/#post-6280974)
 * I encountered the same problem and wrote a workaround using the wpseo_canonical
   Filter and the $_SERVER supervariable.
 * Writing this into your functions.php should return a self-referencing canonical
   with forced http:
 *     ```
       function no_https_canonical( $current_url ) {
   
       		$current_url = 'http://';
       		$current_url .= $_SERVER['HTTP_HOST'];
       		$path = explode( '?', $_SERVER['REQUEST_URI'] );
       		$current_url .= $path[0]; 
   
       		return $current_url;
       	}
   
       	add_filter( 'wpseo_canonical', 'no_https_canonical' );
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Both HTTP and HTTPS canonical tags being generated.’ is closed to new
replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [swagzillionaire](https://wordpress.org/support/users/swagzillionaire/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/both-http-and-https-canonical-tags-being-generated/#post-6280974)
 * Status: not resolved