Post by biwebmaster » Thu Sep 10, 2020 10:30 am

Hello, I want to turn off the search results to Google. As seen in the example, 20-30 pages are indexed. How can I prevent this?

https://prnt.sc/uemncz

Newbie

Posts

Joined
Thu Sep 10, 2020 10:27 am

Post by IP_CAM » Fri Sep 11, 2020 7:26 am


My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by letxobnav » Fri Sep 11, 2020 9:56 am

you can use robots.txt with:

Code: Select all

User-agent: *
Disallow: /*search=*
to prevent seacrh engines from even going there

and/or set robots tags and headers per individual pages to prevent indexing and following

in catalog/controller/common/header.php

Code: Select all

		// index and follow headers
		$data['robots'] = false;
		if (isset($this->request->get['search']) ||
			isset($this->request->get['order']) ||
			isset($this->request->get['sort']) ||
			isset($this->request->get['limit']) ||
			isset($this->request->get['start'])
			) {
			header("X-Robots-Tag: noindex, follow", true);
			$data['robots'] = '<meta name="robots" content="noindex, follow">';
		} elseif (isset($this->request->get['route']) && 
			(
			stristr($this->request->get['route'],'error')
			)
			) {
			header("X-Robots-Tag: noindex, follow", true);
			$data['robots'] = '<meta name="robots" content="noindex, follow">';
		} elseif (isset($this->request->get['route']) && 
			(
			stristr($this->request->get['route'],'checkout/') ||
			stristr($this->request->get['route'],'account/')
			)
			) {
			header("X-Robots-Tag: noindex, nofollow", true);
			$data['robots'] = '<meta name="robots" content="noindex, nofollow">';
		} elseif (isset($this->request->get['route']) && 
			(
			stristr($this->request->get['route'],'FUTURE_PLACEHOLDER')
			)
			) {
			header("X-Robots-Tag: index, nofollow", true);
			$data['robots'] = '<meta name="robots" content="index, nofollow">';
		} else {
			header("X-Robots-Tag: index, follow", true);
			$data['robots'] = '<meta name="robots" content="index, follow">';
		}

then in catalog/view/theme/default/template/common/header.twig

Code: Select all

{% if robots %}
	{{ robots }}
{% endif %}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by Van Quyen » Wed Sep 21, 2022 6:29 pm

letxobnav wrote:
Fri Sep 11, 2020 9:56 am
you can use robots.txt with:

Code: Select all

User-agent: *
Disallow: /*search=*
to prevent seacrh engines from even going there

and/or set robots tags and headers per individual pages to prevent indexing and following

in catalog/controller/common/header.php

Code: Select all

		// index and follow headers
		$data['robots'] = false;
		if (isset($this->request->get['search']) ||
			isset($this->request->get['order']) ||
			isset($this->request->get['sort']) ||
			isset($this->request->get['limit']) ||
			isset($this->request->get['start'])
			) {
			header("X-Robots-Tag: noindex, follow", true);
			$data['robots'] = '<meta name="robots" content="noindex, follow">';
		} elseif (isset($this->request->get['route']) && 
			(
			stristr($this->request->get['route'],'error')
			)
			) {
			header("X-Robots-Tag: noindex, follow", true);
			$data['robots'] = '<meta name="robots" content="noindex, follow">';
		} elseif (isset($this->request->get['route']) && 
			(
			stristr($this->request->get['route'],'checkout/') ||
			stristr($this->request->get['route'],'account/')
			)
			) {
			header("X-Robots-Tag: noindex, nofollow", true);
			$data['robots'] = '<meta name="robots" content="noindex, nofollow">';
		} elseif (isset($this->request->get['route']) && 
			(
			stristr($this->request->get['route'],'FUTURE_PLACEHOLDER')
			)
			) {
			header("X-Robots-Tag: index, nofollow", true);
			$data['robots'] = '<meta name="robots" content="index, nofollow">';
		} else {
			header("X-Robots-Tag: index, follow", true);
			$data['robots'] = '<meta name="robots" content="index, follow">';
		}

then in catalog/view/theme/default/template/common/header.twig

Code: Select all

{% if robots %}
	{{ robots }}
{% endif %}
Hello letxobnav
This works great!!! but i don't understand what is 'FUTURE_PLACEHOLDER' in the code, can you explain it for me?
Thank you!!!

Newbie

Posts

Joined
Wed Jan 09, 2019 3:36 pm

Post by hpwebdesign » Thu Oct 20, 2022 2:34 pm

maybe what is meant by "FUTURE_PLACEHOLDER" is text that you can replace with another route that you don't want to be displayed on google

for example for all information pages you can replace it with information/

or for the contact page you can replace it with information/contact

Attachments

2022-10-20_2.png

2022-10-20_2.png (21.19 KiB) Viewed 3441 times


HP Web Design
Powering Digital Commerce | http://hpwebdesign.io | http://opencart.id
Opencart Professional Services | Create OpenCart Online Store | OpenCart Tutorials


User avatar
Active Member

Posts

Joined
Wed Aug 15, 2018 6:58 am
Location - Yogyakarta

Post by by mona » Thu Oct 20, 2022 9:43 pm

There are basically 4 combinations:
1. index,follow (index this url and follow the urls on it)
2. index,nofollow (index this url but do not follow any urls on it)
3. noindex,follow (no not index this url but follow the urls on it)
4. noindex,nofollow (do not index this url and do not follow any urls on it)

2 is in there as a dummy to have a url/route which you want indexed except for the urls on it.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 23 guests