Author Topic: Custom webpage error messages  (Read 2534 times)

Offline Jay

  • Super Poster
  • ***
  • Posts: 133
    • View Profile
    • http://
Custom webpage error messages
« on: May 12, 2003, 09:01:56 PM »
How would someone create a custom error message, such as "page not found?"  I would like to create one that is a little more friendly than the normal one.  Is this possible?  Or would I have to be using my own personal server to do something like this?

Also, how do I restrict people from going to certain directories.  I would like to block my images folder on my site.  

Thanks everyone smile.gif

Offline Diana

  • Super Poster
  • ***
  • Posts: 410
    • View Profile
Custom webpage error messages
« Reply #1 on: May 12, 2003, 09:41:32 PM »
Hi Jay,

First I have to assume that your webserver is Apache. With this assumption comes another, that your ISP allows you to use .htaccess files in your web space. If those two assumptions are affirmed, then here's a short How-To

Create a web page with your custom text. It's simply that, a normal web page.

Then, create a simple text file and put this type in it. Customize it to your tastes.

ErrorDocument 500 /cgi-bin/crash-recover
ErrorDocument 500 "Sorry, our script crashed. Oh dear
ErrorDocument 500 http://xxx/
ErrorDocument 404 /Lame_excuses/not_found.html
ErrorDocument 401 /Subscription/how_to_subscribe.html

Here is an
Explanation of error codes. Note that the above are the most common and if all you want is the 404, then that is the only line you need.

The file with the above error codes must then be named .htaccess. Note the . (dot) before the h. This is necessary. The dot "hides" the file from the casual viewer so unless your FTP program is set to show you hidden files on the server that file will "disappear" as soon as you FTP it over. Note two: send it in ASCII, not binary.

That's all you need to do. smile.gif

Note three: It's possible that your ISP has already put an .htaccess file in your web space. If this is true, you won't want to overwrite it since you may disable some functionality. If they have done this and they're the least bit concerned that you'll damage that file, the permissions and possibly ownership settings will be such that you can't overwrite it. So, check for this file before you send yours. You can "get" files if you know their name even if you can't see them so try to "get" it first. If you find you can't create one of your own, you'll have to contact the ISP.

Look at these links for examples of custom files:
Example one
Example two
Or, make up a page name after the domain name here at TS and see what happens. smile.gif

Let me know how it goes.

see ya,
Diana
Sysadmin Rule #14: If it's not on fire, it's a software issue.

Registered Linux user 290473
http://counter.li.org/
http://www.crestcomm.com/diana/gnupg.txt for GnuPG public key  

Offline jepinto

  • TS Addict
  • *****
  • Posts: 6195
    • View Profile
    • http://
Custom webpage error messages
« Reply #2 on: May 13, 2003, 05:19:38 AM »
What i've been taught (Hi Diana!) to keep someone from "browsing" a directory is put an index file in the directory.

For instance
http://www.radiks.net/~ghb/ brings up a list of the image files (which I find VERY useful, please don't change it, Snuffysbluff)

http://www.naturecoastrealty.com/images brings up a duplicate of the original index page
Do not fear your enemies.  The worse they can do is kill you.  Do not fear friends.  At worst, they may betray you.
Fear those who do not care; they neither kill nor betray, but betrayal and murder exist because of their silent consent.
~Bruno Jasienski~

Offline Diana

  • Super Poster
  • ***
  • Posts: 410
    • View Profile
Custom webpage error messages
« Reply #3 on: May 13, 2003, 08:28:25 AM »
Morning Jay smile.gif
I forgot to double check to see that all your questions were answered.

Jennie's method is often the best/easiest, especially if you don't have tons of folders below your web folder. The index.html file can be totally blank or you can say something to indicate your intentions.

I have this server set to disallow directory browsing server wide. These are <directives> that are defined for Apache. If it turns out you can manage your own .htaccess files, you can override _some_ server wide directives. In your case, you can disallow directory browsing site wide with one .htaccess file in your web root. This would save you putting an index.html file in ever folder. In the case of my users, they can use their .htaccess files to show their directory lists if they wish to.

An .htaccess file can do multiple things so one .htaccess file will provide for directives, error pages, controlled access such as when you need to password protect something etc. The link above to the explanations about errors can get you started exploring Apache configuration options.

Have fun. smile.gif
Diana
Sysadmin Rule #14: If it's not on fire, it's a software issue.

Registered Linux user 290473
http://counter.li.org/
http://www.crestcomm.com/diana/gnupg.txt for GnuPG public key  

Offline tacit

  • TS Addict
  • *****
  • Posts: 1628
    • View Profile
    • http://www.xeromag.com/
Custom webpage error messages
« Reply #4 on: May 13, 2003, 01:50:43 PM »
All of these suggestions assume that you are running your own Web server and the Web server software is Apache.

If you are not running your own Web server,or you are using something other than Apache, the answer might be different.

Usually, creating your own error pages requires that you have your own server (or that you have permission to modify the server's configuration). You create the custom error pages, then reconfigure the server software to use them.

In most cases, you restrict access to a directory (folder)by modifying a file called .htaccess that lives in that folder. The .htaccess file is not a Web page; it is just a text file that has commands in it telling the server software whether or not to allow access to files and folders.

If you are not running your own server, you'll need to talk to your ISP about whether or not you can change the error pages (you probably can't), and how to create the .htaccess file.
A whole lot about me: www.xeromag.com/franklin.html

Offline Bill

  • TS Addict
  • *****
  • Posts: 4615
    • View Profile
Custom webpage error messages
« Reply #5 on: May 17, 2003, 08:31:51 AM »
Jay.

The server provider could have an option to lock your folders from prying eyes.
I asked mine and they do but I opted to create my own.

Create a basic page. Add background or whatever to it if you like but the less added the faster it loads of course. Put in any text you like.
Example: Stay out of my image folder!

Tag/name it index.html
Upload the created page straight to your image folder because if you don't your main index will be an unhappy camper!


http://www.perrydesigns.com/images/

http://www.perrydesigns.com/images/index.html
Two cans and a string powered by a big mouth

Offline Jay

  • Super Poster
  • ***
  • Posts: 133
    • View Profile
    • http://
Custom webpage error messages
« Reply #6 on: May 17, 2003, 08:43:35 AM »
Thanks everyone!  I appreciate it smile.gifsmile.gif

Jay

Offline Bill

  • TS Addict
  • *****
  • Posts: 4615
    • View Profile
Custom webpage error messages
« Reply #7 on: May 18, 2003, 05:41:18 PM »
*
« Last Edit: May 18, 2003, 08:02:55 PM by Bill »
Two cans and a string powered by a big mouth