Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Custom 404 page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-14-2009, 03:44 PM
 
surfrider surfrider is offline
 

Advanced Member
  
Join Date: Feb 2008
Location: California
Posts: 88
 

Question 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?
__________________
xcart gold 4.1.9
xcart gold 4.1.11
xcart gold 4.1.12
xcart gold 4.4.3
xcart gold 4.6.3
Reply With Quote
  #2  
Old 01-15-2009, 09:40 AM
  WhiteDoveGifts's Avatar 
WhiteDoveGifts WhiteDoveGifts is offline
 

X-Adept
  
Join Date: Oct 2006
Location: Maarssen, The Netherlands
Posts: 474
 

Default 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
__________________
____________________________
X-Cart Gold 4.1.10

EWD Hosting | CDSEO Pro | One Page Checkout | Smart Search | Telafirma Dynamic Images | X-AOM | Product Importer Pro and many custom mods and tweaks found here...
Reply With Quote
  #3  
Old 01-15-2009, 01:44 PM
 
surfrider surfrider is offline
 

Advanced Member
  
Join Date: Feb 2008
Location: California
Posts: 88
 

Default Re: Custom 404 page

Thank you for the step by step instruction. I will give it a try now.
__________________
xcart gold 4.1.9
xcart gold 4.1.11
xcart gold 4.1.12
xcart gold 4.4.3
xcart gold 4.6.3
Reply With Quote
  #4  
Old 01-15-2009, 02:00 PM
 
surfrider surfrider is offline
 

Advanced Member
  
Join Date: Feb 2008
Location: California
Posts: 88
 

Default 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?
__________________
xcart gold 4.1.9
xcart gold 4.1.11
xcart gold 4.1.12
xcart gold 4.4.3
xcart gold 4.6.3
Reply With Quote
  #5  
Old 01-16-2009, 02:40 AM
  WhiteDoveGifts's Avatar 
WhiteDoveGifts WhiteDoveGifts is offline
 

X-Adept
  
Join Date: Oct 2006
Location: Maarssen, The Netherlands
Posts: 474
 

Default 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?
__________________
____________________________
X-Cart Gold 4.1.10

EWD Hosting | CDSEO Pro | One Page Checkout | Smart Search | Telafirma Dynamic Images | X-AOM | Product Importer Pro and many custom mods and tweaks found here...
Reply With Quote
  #6  
Old 01-16-2009, 08:13 AM
 
surfrider surfrider is offline
 

Advanced Member
  
Join Date: Feb 2008
Location: California
Posts: 88
 

Default 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.
__________________
xcart gold 4.1.9
xcart gold 4.1.11
xcart gold 4.1.12
xcart gold 4.4.3
xcart gold 4.6.3
Reply With Quote
  #7  
Old 01-16-2009, 10:58 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default 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
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:33 AM.

   

 
X-Cart forums © 2001-2020