Jump to content
xisto Community
mzwebfreak

Custom Error Pages

Recommended Posts

I think this goes in here, since you need cpanel to make them, but how does one go about making custom error pages so that you see something different than the usual "This page is unavailable". I mean, for my domain, I want the 404s and such to give them links back to certain points in my domain. Any idea how to do that?

Share this post


Link to post
Share on other sites

I think this goes in here, since you need cpanel to make them, but how does one go about making custom error pages so that you see something different than the usual "This page is unavailable".  I mean, for my domain, I want the 404s and such to give them links back to certain points in my domain.  Any idea how to do that?

1064326331[/snapback]


Look here for cpanel specific instructions:

 

https://www.visn.co.uk/cpanel-docs/error-pages.html

 

and here for more general information about apache, php and error pages:

 

http://www.onlamp.com/pub/a/onlamp/2003/02davidsklar.html

 

In short, you must instruct Apache to use the custom pages by putting directives in the .htaccess file. Cpanel has some support for doing this for you. If you want smart error pages (e.g.: doing a site search and coming back with related pages), you need to do some PHP work.

Share this post


Link to post
Share on other sites

Here's some images that I got from the Big Nose Bird, just do a google for him and you can get the PERL script and install intructions but they are kinda neat. Just take a look.

Unknown error 000Posted Image

A bad request error 400Posted Image

Improper authorization error 401Posted Image

How did you get this address (a private address?) error 403Posted Image

The familiar page not found error 404Posted Image

Server (cgi script bad) error 500Posted Image

 

The script is small and not that hard to install plus it will guide you through making your own HTML so you can do what you want whether you use the images or not, you can always make your own ones.

Share this post


Link to post
Share on other sites

Well you can make your own custom Error Pages, just use an .htaccess file in your public_html dir:

ErrorDocument 400 badrequest.phpErrorDocument 401 authorization.phpErrorDocument 403 forbidden.phpErrorDocument 404 wrongpage.phpErrorDocument 500 internal.php

you can show the path to the files whereever you want and your php code in those files will be executed, you can use your own layout and the and everything you want.

I think I have done something like this erlier, but it might not work, just create an 404.shtml file on your root or better to say public_html directory and use the code there:

<!--#include virtual="/home/user/public_html/error/wrongpage.php" --><!--                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         -->

Hope this helps :)

Share this post


Link to post
Share on other sites

There is actually a module of you cPanel that can do this for you, making it much easier.Look under the "Site Managment Tools" section, and find Custom Error Pages (furthest on the right, second row).Choose the error you would like to make a page for, and fill in the box with the HTML you want to use on your error page.When you do images, make sure to use the full URL for them.

Share this post


Link to post
Share on other sites

I saw that in cpanel, but wasn't entirely sure how to go about doing it, but I guess you just treat it like any other HTML document? Do I need to have the header section and such like that, or, if I'm doing that, would it simply be better to use the .htaccess file way instead? And by full image path, I assume you mean something such as http://forums.xisto.com/no_longer_exists/? Just trying to make sure I have everything right.

Share this post


Link to post
Share on other sites

Yeah, just do it as you would with any other HTML document.And yes, that's what I mean by a full image path (you'll need to do it with links too, I forgot to mention it in my old post)The cPanel tool basically does the .htaccess for you, so doing the .htaccess method would probably yield the same results. I just posted this because I think it's easier to use, and thought it would be helpful.

Share this post


Link to post
Share on other sites

The cPanel tool basically does the .htaccess for you, so doing the .htaccess method would probably yield the same results. I just posted this because I think it's easier to use, and thought it would be helpful.

This is nice if you are getting started with .htaccess and stuff, but if you know a little more and don't want to get used to this new way, then I would strongly recommend using the .htaccess way, that Quatrux described. Not only can you set up pages for EVERY error code but you can also use pages that already exist (like the Sitemap with a little 404-notice) without having to define them newly inside the Cpanel. I also had problems with PHP inside the cpanel (wouldn't read it), so this is why I considered the other method in the first place. But it is really much more advanced. I haven't found a way to give different error pages for different folders in the Cpanel. In .htaccess this is easy. I am especially fond of that, because I got a different page on a subdomain and it shouldn't use the same error pages.
It also makes it easier to move with the whole site. Hope this lined out pros and cons,
// Ruben

Share this post


Link to post
Share on other sites

Okay, so what you're saying is that .htaccess with them reading PHP files off of the root directory means that if I type in a wrong URL on the root directory, my special error page will show up, but if it's one of the subdomains, it won't, unless I have the same .htaccess format, with corresponding pages, in that subdirectory's folder?But, if I use the Cpanel method, since I'm posting the files/graphics with the full image path, it will work the same on both the root directory and subdomains?Just trying to make sure I've got this all straight, because I really don't wanna try and work on it only to have to do it again 45 different times (cuz that's how many subdomains I have).

Share this post


Link to post
Share on other sites

I have not actually tried!

But what you said is what I suppose to happen, because there is only one error page setup in the whole control panel. The .htaccess works on other servers I know, but yesterday I tried (not long) and didn't succeed, so you might want to wait for someone with more experience.

Of course you can already try now what the Cpanel configuration does (it's not that much work and you will easily find out). Just try some wrong URls and look if the error pages are the same everywhere. Good luck and let us hear your results. I'm going to work on it too the next days.

Share this post


Link to post
Share on other sites

Err years ago when I used cpanel for my error pages, I think it made 404.shtml file (other errors) with what I wrote in the form and it did not do anything in .htaccess, but now it might be different.

Share this post


Link to post
Share on other sites

I did a little research on it now... It is kind of screwed up, because using your own .htaccess file does not work for me (directly) and the Cpanel option neither (false address generates a 404 error "but 500 because no error document could be found". REALLY messed up. anyone got more experience with this than I have?bye, ruben

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.