X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Custom 404 page (https://forum.x-cart.com/showthread.php?t=44810)

surfrider 01-14-2009 03:44 PM

Custom 404 page
 
What is the best way to create custom 404 page? Is there mod for custom 404 page that can have search box to search through the site?

WhiteDoveGifts 01-15-2009 09:40 AM

Re: Custom 404 page
 
Hi,

I had the exact same questions for my own site but somehow I cannot find my thread back!

With the feedback from the forum guys this is basically what I did and it works like a charm for me:

1) look in your X-Cart root for the following file: error_message.php and empty the contents.

2) Open your home page in a browser and copy all the code over to error_message.php

3) Put this line of code on top of the code on the first line.

<?php header("HTTP/1.0 404 Not Found"); ?>

This ensures your site returns a proper 404 header when the error page is called.

4) Change your page title into something like "This page could not be found. Error 404" or similar.

5) Edit your welcome text with some text explaining how the user might have gotten there and some suggestions what to do next like:

"Oops, were sorry. The requested page was not found or might have been moved. Maybe you followed an invalid link or made a typo in your address bar. We like to know how you got here and appreciate if you contact us."

6) Save and upload the error_message.php to your root and check. Now you should have a nice looking custom 404 page with all your navigations and search working. And the best thing is that your featured products are shown as well :)

Alternatively you can add specialized code from Google Webmaster Tools that will put a Google search box on your error page called: Enhance 404 pages

You can find it in the "Tools" section of your Google Webmaster tools account.
Haven't tested it myself since I am using Altered Cart Smart Search which works very well instead...

Hope you find this information useful for creating your own custom 404 error page.

Cheers,
Nico

surfrider 01-15-2009 01:44 PM

Re: Custom 404 page
 
Thank you for the step by step instruction. I will give it a try now.

surfrider 01-15-2009 02:00 PM

Re: Custom 404 page
 
Is there way to make the URL stay the same on 404 error instead of jumping it to error_message.php?page_not_found=&error404=asdf?

WhiteDoveGifts 01-16-2009 02:40 AM

Re: Custom 404 page
 
I don't know if that's possible, is there a reason why you'd want to prevent the url from changing?

surfrider 01-16-2009 08:13 AM

Re: Custom 404 page
 
I want to make a little useful 404 page so it displays what page user was trying to reach. I could get the URL by PHP script but if the URL redirect, I cannot get the original URL.

Jon 01-16-2009 10:58 AM

Re: Custom 404 page
 
You need to find where in your xcseo code that the redirect is taking place and through a 404 header and echo an error at that time. (If this portion of the xcseo code is unencrypted).

Jon Peters


All times are GMT -8. The time now is 01:38 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.