Originally Posted by
dreamscape
Here is how you can get 404 headers to be sent. This is from the archives, so I'll post it here.
Well first off the issue is really due to the fact that Zen Cart does not send 404 headers. If you turn SEO off or on a shop with it turned off, and you can go to index.php?main_page=gobbledeygook, you will get an HTTP 200 OK header (and most likely the index page). It's just that the issue is a bit more noticeable with SEO installed, but it exists in a plain vanilla Zen Cart install as well.
You can send 404 headers on invalid pages by doing this (for 1.3):
- Open file includes/init_includes/init_sanitize.php
- Find on line 105 or thereabout:
PHP Code:
if (!is_dir(DIR_WS_MODULES . 'pages/' . $_GET['main_page'])) {
- Add after:
PHP Code:
header('HTTP/1.1 404 Not Found');
I don't want google to penalize me for duplicate page names.. I read about this fix, do you think it's still necessary in the latest version?
That will give a 404 header to user agents (including search bots) on invalid pages.
Is this still necessary on 1.3.8a?
So on 1.3.8a it should look like
PHP Code:
if (!is_dir(DIR_WS_MODULES . 'pages/' . $_GET['main_page'])) {
header('HTTP/1.1 404 Not Found');
if (MISSING_PAGE_CHECK == 'On' || MISSING_PAGE_CHECK == 'true') {
$_GET['main_page'] = 'index';
} elseif (MISSING_PAGE_CHECK == 'Page Not Found') {
header('HTTP/1.1 404 Not Found');
$_GET['main_page'] = 'page_not_found';
}
instead of
PHP Code:
if (!is_dir(DIR_WS_MODULES . 'pages/' . $_GET['main_page'])) {
if (MISSING_PAGE_CHECK == 'On' || MISSING_PAGE_CHECK == 'true') {
$_GET['main_page'] = 'index';
} elseif (MISSING_PAGE_CHECK == 'Page Not Found') {
header('HTTP/1.1 404 Not Found');
$_GET['main_page'] = 'page_not_found';
}
If I do this and type in gobbledygook
THANKS!
Bookmarks