Jim
https://www.carguygarage.com
Yahoo Store since 2006 moved to OpenCart on January 24, 2020
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
This is exactly because the availability of those pages can vary and they rarely add search engine value.
Today you may have page=10 content, tomorrow you may only have up to page=9.
Redirecting page=10 to your home page is a bad idea.
So ideally, do not allow indexing of those, via htaccess and/or x-robot headers/meta-tags.
If they already are, give a 404 or a 410 when the page number requested exceeds the number-of-pages value you have in your controller, this would require a small alteration though.
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
Code: Select all
.....
Disallow: /*&tag=
Disallow: /*?tag=
Disallow: /*&filter_name=
Disallow: /*?filter_name=
Disallow: /*?route=checkout/
Disallow: /*&route=checkout/
Disallow: /*?route=account/
Disallow: /*&route=account/
Disallow: /*?route=product/search
Disallow: /*&route=product/search
Disallow: /*?route=product/product/review
Disallow: /*&route=product/product/review
Disallow: /*?route=information/information/agree
Disallow: /*&route=information/information/agree
Disallow: /*?page=1
Disallow: /*&page=1
Disallow: /*?route=affiliate/
Disallow: /*&route=affiliate/
Disallow: /*?keyword=
Disallow: /*&keyword=
Disallow: /*?order=
Disallow: /*&order=
Disallow: /*?sort=
Disallow: /*&sort=
.....
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Version 3.0.3.2straightlight wrote: ↑Thu Sep 02, 2021 6:05 amOC version. So, what are you referring about exactly?
I see this page in Google SERPS -
Code: Select all
https://www.carguygarage.com/storage/cabinets/polished-stainless-steel-cabinets?page=2
Code: Select all
https://www.carguygarage.com/accessories/decor?sort=pd.name&order=DESC&limit=isjfgyevlvttii
####################################################################
I would redirect to the main category page without parameters although a 404 would be fine too. I'm asking if anyone has made the code change yet and would share? Otherwise I'll have to dive in and figure it out.by mona wrote: ↑Thu Sep 02, 2021 3:34 pmRedirecting page=10 to your home page is a bad idea.
So ideally, do not allow indexing of those, via htaccess and/or x-robot headers/meta-tags.
If they already are, give a 404 or a 410 when the page number requested exceeds the number-of-pages value you have in your controller, this would require a small alteration though.
####################################################################
Thanks, but I do want valid page 2 etc crawled so the products on those pages are indexed and this would prevent that.
Jim
https://www.carguygarage.com
Yahoo Store since 2006 moved to OpenCart on January 24, 2020
Code: Select all
Disallow: /*?page=1
Disallow: /*&page=1
Code: Select all
Disallow: /*page=
in your header.php controller:
Code: Select all
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['page'])
) {
header("X-Robots-Tag: noindex, follow", true);
$data['robots'] = '<meta name="robots" content="noindex, follow">';
} else {
header("X-Robots-Tag: index, follow", true);
$data['robots'] = '<meta name="robots" content="index, follow">';
}
Code: Select all
// index and follow headers
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['page']) ||
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/') ||
stristr($this->request->get['route'],'checkout/') ||
stristr($this->request->get['route'],'account/') ||
stristr($this->request->get['route'],'affiliate/')
)
) {
header("X-Robots-Tag: noindex, nofollow", true);
$data['robots'] = '<meta name="robots" content="noindex, nofollow">';
} else {
header("X-Robots-Tag: index, follow, noarchive", true);
$data['robots'] = '<meta name="robots" content="index, follow, noarchive">';
}
Code: Select all
{{ robots }}
This you cannot do with htaccess where you can only request the search engines not to request the page in the first place and therefore they will also not pick up any links these contain.
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
Ah, interesting approach! This looks like a good idea!
I was just looking at the /catalog/controller/product/category.php
And made a quick change to test. I'd have to do this for all the available parameters, but I like your idea better.
Code: Select all
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
if( (!is_numeric($limit)) || (floor($limit) != $limit) ){
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
}
Jim
https://www.carguygarage.com
Yahoo Store since 2006 moved to OpenCart on January 24, 2020
head_dunce wrote: ↑Thu Sep 02, 2021 6:55 pmAh, interesting approach! This looks like a good idea!
I was just looking at the /catalog/controller/product/category.php
And made a quick change to test. I'd have to do this for all the available parameters, but I like your idea better.Code: Select all
if (isset($this->request->get['limit'])) { $limit = $this->request->get['limit']; if( (!is_numeric($limit)) || (floor($limit) != $limit) ){ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); }
Code: Select all
$limit = $this->request->get['limit'];
Code: Select all
$limit = (int)$this->request->get['limit'];
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Check your pages have the correct canonical links and that you have correctly configured the URL Parameters for your site in Google's Search console. The canonical links should take care on any duplicates caused by URL parameters other than page.head_dunce wrote: ↑Thu Sep 02, 2021 6:55 pmAh, interesting approach! This looks like a good idea!
I was just looking at the /catalog/controller/product/category.php
And made a quick change to test. I'd have to do this for all the available parameters, but I like your idea better.Code: Select all
if (isset($this->request->get['limit'])) { $limit = $this->request->get['limit']; if( (!is_numeric($limit)) || (floor($limit) != $limit) ){ $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); }
Be careful of adding noindex (and possibly 404) to pages that have a canonical link to a page you need to be indexed. It's something Google warn against doing. https://developers.google.com/search/do ... age%20when
For the original page issue. You could try. After.
Code: Select all
$results = $this->model_catalog_product->getProducts($filter_data);
Code: Select all
if (!$results && (int)$page != 1) {
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
}
Actually that's a problem, and that's how the original OC source code has it. If what's supplied is not a number, (int) will return zero.straightlight wrote: ↑Thu Sep 02, 2021 7:32 pmfor:Code: Select all
$limit = $this->request->get['limit'];
Code: Select all
$limit = (int)$this->request->get['limit'];
By using (!is_numeric($limit)) || (floor($limit) != $limit) you're able to check if it is a number and if it is an integer. If what was supplied was anything else, it should just give a 404 since whatever was given was not supplied by OC. As noted above, I am showing links in Google Search Console with "limit=" being random strings. No idea how or why Google found those pages, but OC shouldn't be allowing them anyway.
Jim
https://www.carguygarage.com
Yahoo Store since 2006 moved to OpenCart on January 24, 2020
The URL Parameters in Google Search Console is a legacy tool, so I'm not sure how long that will stick around. I see what you mean about the canonical, the "page=" seems to be the only parameter passed to the canonical link (sort, order, and limit are not passed to the canonical link.)ADD Creative wrote: ↑Thu Sep 02, 2021 8:28 pmCheck your pages have the correct canonical links and that you have correctly configured the URL Parameters for your site in Google's Search console. The canonical links should take care on any duplicates caused by URL parameters other than page. Be careful of adding noindex (and possibly 404) to pages that have a canonical link to a page you need to be indexed. It's something Google warn against doing. https://developers.google.com/search/do ... age%20when
So this begs the question can I set the canonical link to be an error page after -ADD Creative wrote: ↑Thu Sep 02, 2021 8:28 pmFor the original page issue. You could try. After.Add.Code: Select all
$results = $this->model_catalog_product->getProducts($filter_data);
But again this could cause issues if the limit is set. For example category?page=2&limit=100 would return no products and a 404, but the canonical link to category?page=2 would be valid and require indexing.Code: Select all
if (!$results && (int)$page != 1) { $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); }
Code: Select all
if (!$results && (int)$page != 1) {
$this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found');
}
Jim
https://www.carguygarage.com
Yahoo Store since 2006 moved to OpenCart on January 24, 2020
May cause an undefined variable error message in the error triggers if it's not sanitized, that's why.head_dunce wrote: ↑Thu Sep 02, 2021 11:16 pmActually that's a problem, and that's how the original OC source code has it. If what's supplied is not a number, (int) will return zero.straightlight wrote: ↑Thu Sep 02, 2021 7:32 pmfor:Code: Select all
$limit = $this->request->get['limit'];
Code: Select all
$limit = (int)$this->request->get['limit'];
By using (!is_numeric($limit)) || (floor($limit) != $limit) you're able to check if it is a number and if it is an integer. If what was supplied was anything else, it should just give a 404 since whatever was given was not supplied by OC. As noted above, I am showing links in Google Search Console with "limit=" being random strings. No idea how or why Google found those pages, but OC shouldn't be allowing them anyway.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Yeah, but if it's not a positive integer then OC should return the 404 or do something else besides generating the page as if all is well. You can sanitize it after it's checked to avoid the php error if you'd like.straightlight wrote: ↑Fri Sep 03, 2021 12:06 amMay cause an undefined variable error message in the error triggers if it's not sanitized, that's why.
Jim
https://www.carguygarage.com
Yahoo Store since 2006 moved to OpenCart on January 24, 2020
Cinderella request. Browsers requires that the variable gets sanitized before the load completes, not after.head_dunce wrote: ↑Fri Sep 03, 2021 12:15 amYeah, but if it's not a positive integer then OC should return the 404 or do something else besides generating the page as if all is well. You can sanitize it after it's checked to avoid the php error if you'd like.straightlight wrote: ↑Fri Sep 03, 2021 12:06 amMay cause an undefined variable error message in the error triggers if it's not sanitized, that's why.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Huh? Try on this glass slipper, let me know if this fits for you - you know the OC code best, I'm just trying to fix this SEO problemstraightlight wrote: ↑Fri Sep 03, 2021 1:18 amCinderella request. Browsers requires that the variable gets sanitized before the load completes, not after.
/catalog/controller/product/category.php
Code: Select all
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
if( (!is_numeric($limit)) || (floor($limit) != $limit) || ($limit < 1) ){
$this->response->redirect($this->url->link('error/not_found'));
}
Jim
https://www.carguygarage.com
Yahoo Store since 2006 moved to OpenCart on January 24, 2020
Building on this, it seems like this might be the answer to the problem of pages with no productsADD Creative wrote: ↑Thu Sep 02, 2021 8:28 pmFor the original page issue. You could try. After.Add.Code: Select all
$results = $this->model_catalog_product->getProducts($filter_data);
But again this could cause issues if the limit is set. For example category?page=2&limit=100 would return no products and a 404, but the canonical link to category?page=2 would be valid and require indexing.Code: Select all
if (!$results && (int)$page != 1) { $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . ' 404 Not Found'); }
/catalog/controller/product/category.php
Code: Select all
if (!$results && (int)$page != 1) {
$this->response->redirect($this->url->link('error/not_found'));
}
Jim
https://www.carguygarage.com
Yahoo Store since 2006 moved to OpenCart on January 24, 2020
Code: Select all
$this->response->redirect($this->url->link('error/not_found', 301));
Code: Select all
$this->response->redirect($this->url->link('product/category', 'path=' . $category_info['category_id'], 301));
Code: Select all
if (!$results && (int)$page != 1) {
$this->response->redirect($this->url->link('error/not_found'));
}
When a request is made for page=10 but page 10 does not exist (given the number of products and the limit), you could give a 404 and when you do not let page= be indexed requests for them should not happen unless manually entered.
Code: Select all
// non-existent pages (requested page > number of pages)
if (!empty($this->request->get['page'])) {
if (ceil($product_total / $limit) < $this->request->get['page']) {
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true);
exit();
}
}
However, when a page does not yield products, you simply state that no products are found, you do not give a 404, the page exists, the products don't.
You could have combinations of filters, price ranges, search keywords, etc. which simply yield no products.
In short, the $results are irrelevant for a 404 response.
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
Code: Select all
// non-existent pages (requested page > number of pages)
if (isset($this->request->get['page'])) {
if (ceil($product_total / $limit) < (int)$this->request->get['page']) {
$this->response->redirect($this->url->link('product/category', 'path=' . $category_info['category_id'], 301));
exit();
}
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
// non-existent pages (requested page > number of pages)
if (isset($this->request->get['page'])) {
if (ceil($product_total / $limit) < (int)$this->request->get['page']) {
$this->response->redirect($this->url->link('product/category', 'path=' . $category_info['category_id'], 301));
exit();
}
}
This is not correct as search engines cache 301 permanent redirects.
Today you may not have a page 10, so you give a permanent redirect to the base page.
Tomorrow you may have a page 10 but since the search engine remembers the redirect it will not request that page but again retrieve the base page.
Then better do a 302 redirect which is not cached.
But if it is your goal to have indexed urls with page= querystring parameters removed from the index, you need to give a 404 or better a 410 or they will not remove them from the index.
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
Users browsing this forum: No registered users and 14 guests