Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Custom error pages!


Guest

Recommended Posts

If you got my site and click www.formulaframed.com/your_name.html you will get not the usual 404 error page but a custom page that looks like the rest of your site. Dont fill this form in though, unless you want to say hi :)

 

Here is what I did.

 

Create a file named .htaccess in NotePad. Upload this to your main web directory, and make sure it includes something like this. Or add these lines to your existing .htaccess file if you have one.

 

ErrorDocument 404 http://1234.com/opss.php

 

ErrorDocument 500 http://1234.com/opss.php

 

ErrorDocument 401 http://1234.com/opss.php

 

What I did was make a copy of the contact page from OS, renamed it opss, and then changed a few things like the text and title and the subject of the email it generates. Then make sure the link above (http://1234.com/opss.php)points to wherever you save the new opss file!!

 

I hope that helps

 

may not work with some contributions though?? Let me know!

Link to comment
Share on other sites

Or better: redirect them to a php script that analyzes the requested url and feeds its keywords to advanced_search.php

 

Mattice

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

Yep you could do that, but if you have no idea whatsoever how to do that, coz your a newbie like me :? , then my idea is quite handy :lol: . Also if like me you dont have search enabled. :shock:

 

But mattices idea is better in the long run, maybe he should post it as a contribution ;)

Link to comment
Share on other sites

I was not saying your idea was'nt handy/good. :D

It's just better to forward people to 'content' instead of something they will have to fill in.

I wouldn't even consider it (as a surfer) and would just leave on the page you provide me with.

 

You test it. If it works you make it into a nice contribution okay? :D

 

<?php 



// set search uri

  $search = 'http://www.yoursite.com/advanced_search_result.php?search_in_description=1';



// drop what they're looking for in an array

 $pieces = explode('/', strtolower($REQUEST_URI));



// no doubles

 $pieces = array_unique($pieces);



/*

   Depending on the structure your old site had you might want

   to change the value of $i. 

   if we we're asked www.yoursite.com/oldshop/computer/monitor/bla.html    

   

   $pieces[0] will hold 'oldshop' and should not be counted.

    

    so $i should be 1.

    We're also not counting the last entry as it will be the html file.

*/



$i = 1; //see comments above 

$keywords = '&keywords=';



 while ($i < count($pieces) -1) {

   $i++;

          $keywords .= $pieces[$i] . '+';

 }



// build the uri

 $search = $search . $keywords . $type;



// give it to them:

 header("Location: $search");

?>

 

Regards,

Mattice

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

  • 2 weeks later...
I thought this was a good idea, so I implemented it:

http://www.oscommerce.com/community/contributions,940

 

You can see a live version at:

http://www.thecandlefactory.com/badURLTEst/p-951.html

 

Note, this is live shop!!

 

Thanks for contributing, result looks nice!

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

I thought this was a good idea, so I implemented it:

http://www.oscommerce.com/community/contributions,940

 

You can see a live version at:

http://www.thecandlefactory.com/badURLTEst/p-951.html

 

Note, this is live shop!!

 

It looks nice but I wanted to let you know that you have some grammatical errors in the page.

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

  • 1 month later...

This is a really cool contribution BUT...

 

In the instance of my site, I use the www.domain.com/catalog/structure/default.php whereas your default.php is in the root.

 

In my site, a bad request to www.domain.com/whatever returns proper results in the search results.

 

A bad request to www.domain.com/catalog/whatever returns every item in the shop in the search results.

 

I tried to make a $patterns[0] = '/catalog/'; entry but that makes the advance search page come up on a bad request.

 

Any ideas?

 

Thanks,

Mr. Ree

How to find answers to OSC Common Questions

1. Look at http://wiki.oscommerce.com

2. Search http://www.oscommerce.com/forums/

3. Post a request in http://www.oscommerce.com/forums/

Link to comment
Share on other sites

I hate figuring it out 30 seconds after I post.

 

The answer is to call a pattern such as $patterns[2] = '/catalog/';

and rather than having $replacements[2] = '';

make it $replacements[2] = 'workdamnit';

 

or any word not likely to be found in your products.

 

Thanks for the great Contribution and sorry fr my denseness.

Mr. Ree

How to find answers to OSC Common Questions

1. Look at http://wiki.oscommerce.com

2. Search http://www.oscommerce.com/forums/

3. Post a request in http://www.oscommerce.com/forums/

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...