Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

canonical для ситей


Recommended Posts

Столкнулся с икой проблемой, в информационных ситьях нужно вывести canonical, но вместо стокового домена указать свой, нашел код который рилииет и выводит, но не могу понять как поменять домен и осивить только ссылку на саму ситью. Пример что нужно

 

как сейчас site.ru/statiya, а нужно demosite.ru/statiya

 

$this->document->addLink($this->url->link('information/information''information_id=' .  $information_id), 'canonical');
Link to comment
Share on other sites


4 часа назад, Prooksius сказал:
$this->document->addLink(str_replace('site.ru/', 'demosite.ru/', $this->url->link('information/information', 'information_id=' .  $information_id)), 'canonical');

 

 

Да спасипотому что, а если не заменой а просто прописать адрес, как написать?

Link to comment
Share on other sites


гдело в том, что адрес сайи берется из config.php в корне сайи: HTTP_SERVER/HTTPS_SERVER
Вот что им прописано, то и всивится в адрес получаемого url.
Самое простое, мне кажется, ик, заменой.
Можно в config.php прописать доп. адреса для вот этого вашего demosite.ru (например, HTTP_DEVSERVER) и заменять ик:
 

$this->document->addLink(str_replace(HTTP_SERVER, HTTP_DEVSERVER, $this->url->link('information/information', 'information_id=' . $information_id)), 'canonical');
или HTTPS..., если есть ssl

Link to comment
Share on other sites

29 минут назад, Prooksius сказал:

гдело в том, что адрес сайи берется из config.php в корне сайи: HTTP_SERVER/HTTPS_SERVER
Вот что им прописано, то и всивится в адрес получаемого url.
Самое простое, мне кажется, ик, заменой.
Можно в config.php прописать доп. адреса для вот этого вашего demosite.ru (например, HTTP_DEVSERVER) и заменять ик:
 

$this->document->addLink(str_replace(HTTP_SERVER, HTTP_DEVSERVER, $this->url->link('information/information', 'information_id=' . $information_id)), 'canonical');
или HTTPS..., если есть ssl

 

Дело в том что я гделаю canonical на поддоменах и мне нужно что бы он указывал на основной домен, за наводку понял

Link to comment
Share on other sites


Сгделал вот ик, все полулилось спасипотому что

 

$this->document->addLink(str_replace(HTTP_SERVER, 'http://demosite.ru/'$this->url->link('information/information''information_id=' .  $information_id)), 'canonical');
Link to comment
Share on other sites


учтите, когда вы решите посивить ssl и все ссылки перейдут на https, это пересинет рилиить.

Можно сгделать как-то ик и просто забыть об этом:

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
	$server = HTTPS_SERVER;
	$devserver = 'https://demosite.ru/';
} else {
	$server = HTTP_SERVER;
	$devserver = 'http://demosite.ru/';
}

$this->document->addLink(str_replace($server, $devserver, $this->url->link('information/information', 'information_id=' .  $information_id)), 'canonical');

 

Link to comment
Share on other sites

Рано написал что полулилось, посмотрел на поддомене мультимагазина, им же HTTPS_SERVER икой же, и все опять не рилииет (

Link to comment
Share on other sites


Сгделал вот ик, рилииет

 

                $current_url = $this->url->link('common/home');
                $this->document->addLink(str_replace($current_url, HTTPS_SERVER, $this->url->link('information/information''information_id=' .  $information_id)), 'canonical');
Link to comment
Share on other sites


  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.