topvip
2012-04-08, 07:59 AM
This custom 404 page is part of the default Zen Cart shopping cart framework. It is expected that you customize this 404 page by replacing the sample text with your own wording. You can edit the wording for the page by changing it in the /languages/english/html_includes/classic/define_page_not_found.php file. If your site is in a different language or uses a custom template, then the directory for changing the text would be different: you’d substitute your language for english and your template name for classic in the folder path.
The file that constructs this custom Zen Cart 404 page is located here: /includes/modules/pages/page_not_found/header_php.php. After displaying the “You’re trying to access a page that doesn’t exist” message, this file then inserts your web site’s sitemap.
Although the Zen Cart custom 404 page is a step up from the leave-me-stranded error page that shows up if nothing is configured on the web site for a custom 404 page, many webmasters feel that a page that sends any kind of message to the visitor that there has been an error creates bad karma. It’s common for me to simply re-route the bad request to the site’s home page, where users can then search for the product they want without feeling like they’ve started out on a bad foot. Here’s how to change your Zen Cart store so that 404 errors are simply routed back to the home page.
Open /includes/modules/pages/page_not_found/header_php.php. You should see two lines near the top of the file that look like this:
// tell the browser that this page is showing as a result of a 404 error:
header(‘HTTP/1.1 404 Not Found’);
Beneath the second line, you need to enter an HTTP command that tells the browser to go to the site’s home page. That command can be accomplished by the line shown below in bold.
// tell the browser that this page is showing as a result of a 404 error:
header(‘HTTP/1.1 404 Not Found’);
header(‘Location: /index.php’);
It should be intuitive that you can forward the 404 error response to whatever page you’d like by substituting the desired forwarding page in place of /index.php.
You can try:
header('location: http://www.bestpriceglasses.com');
header('location: /index.php');
The file that constructs this custom Zen Cart 404 page is located here: /includes/modules/pages/page_not_found/header_php.php. After displaying the “You’re trying to access a page that doesn’t exist” message, this file then inserts your web site’s sitemap.
Although the Zen Cart custom 404 page is a step up from the leave-me-stranded error page that shows up if nothing is configured on the web site for a custom 404 page, many webmasters feel that a page that sends any kind of message to the visitor that there has been an error creates bad karma. It’s common for me to simply re-route the bad request to the site’s home page, where users can then search for the product they want without feeling like they’ve started out on a bad foot. Here’s how to change your Zen Cart store so that 404 errors are simply routed back to the home page.
Open /includes/modules/pages/page_not_found/header_php.php. You should see two lines near the top of the file that look like this:
// tell the browser that this page is showing as a result of a 404 error:
header(‘HTTP/1.1 404 Not Found’);
Beneath the second line, you need to enter an HTTP command that tells the browser to go to the site’s home page. That command can be accomplished by the line shown below in bold.
// tell the browser that this page is showing as a result of a 404 error:
header(‘HTTP/1.1 404 Not Found’);
header(‘Location: /index.php’);
It should be intuitive that you can forward the 404 error response to whatever page you’d like by substituting the desired forwarding page in place of /index.php.
You can try:
header('location: http://www.bestpriceglasses.com');
header('location: /index.php');