This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
Canonical tag
« on: December 12, 2023, 10:41:39 PM »
Hello, I apologize for the fact that I am looking in the wrong category. I need your help. when I enable the "Canonical tag Always Generate Canonical URL tag. It is generated on every page (not just search)" function in the admin panel. the code displays http:// but I need https:// how to fix this
« Last Edit: December 13, 2023, 12:09:29 AM by Дима Пупкин »

*

MB Themes

Re: Canonical tag
« Reply #1 on: December 13, 2023, 10:28:31 AM »
Why you think it should work just on search page?

here is code used to get URL:
Code: [Select]
function osc_get_current_url() {
  if(isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) {
    return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  }

  return false;
}

I would say if you get http, then your server variable has https off.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Canonical tag
« Reply #2 on: December 13, 2023, 11:31:57 AM »
Sorry, I worded the question incorrectly. when I enable the "Canonical tag" feature in the admin panel. The conanical link is generated by the http:// protocol. although I have an SSL certificate configured and the entire site runs on https://, only the conanical link is generated by http://. Tell me what needs to be fixed so that the "Canonical tag" generates the link https://

*

MB Themes

Re: Canonical tag
« Reply #3 on: December 13, 2023, 01:47:26 PM »
Means $_SERVER['HTTPS'] <> 'on'
Check with your hosting
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Marked as best answer by Дима Пупкин on December 13, 2023, 10:23:06 PM
*

MB Themes

Re: Canonical tag
« Reply #4 on: December 13, 2023, 01:52:36 PM »
You may also try to udpate that function (in oc-includes/osclas/utils.php) into:
Code: [Select]
function osc_get_current_url() {
  if(isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) {
    return (osc_is_ssl() ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  }

  return false;
}
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

Re: Canonical tag
« Reply #5 on: December 13, 2023, 10:22:55 PM »
Thank you for your help and work, you are the best. everything works as it should!