change 'not found' page

L

Lloyd

Is there a way to change what a person sees on my site when they type in,
or get a bad url?
I see this:
The page cannot be found
On other sites I see different messages, I would like to customise mine.
Thanks in advance,
Lloyd
 
N

Neal

Is there a way to change what a person sees on my site when they type
in,
or get a bad url?
I see this:
The page cannot be found
On other sites I see different messages, I would like to customise mine.

This assumes you are on an Apache or similar server.

Create an error page, save it as say "error.html".

Then in a blank document add this line:

ErrorDocument 404 http://www.example.com/error.html

replacing your domain and path to the error document for the example path
above.

Save this file to your root directory with the name ".htaccess" - dot and
all.
 
L

Lloyd

This assumes you are on an Apache or similar server.

Create an error page, save it as say "error.html".

Then in a blank document add this line:

ErrorDocument 404 http://www.example.com/error.html

replacing your domain and path to the error document for the example path
above.

Save this file to your root directory with the name ".htaccess" - dot and
all.

Thak you! I'll give it a shot
Merry Christmas......
 
L

Lloyd

Create an error page, save it as say "error.html".
Then in a blank document add this line:

ErrorDocument 404 http://www.example.com/error.html

replacing your domain and path to the error document for the example path
above.

Save this file to your root directory with the name ".htaccess" - dot and
all.

it's an Apache server, I followed all instructions:
it would not let me make a file called .htaccess on my win xp so after I
uploaded it using cuteftp, I renamed it and it disappeared! When I type a
bad url in, it just does nothing, (xp flag keeps waving)
How to I find my .htacess if I need to edit it?
Thanks
Lloyd
 
N

Neal

it would not let me make a file called .htaccess on my win xp so after I
uploaded it using cuteftp, I renamed it and it disappeared!

XP probably does not recognize it as real, it's pretty stupid.
When I type a
bad url in, it just does nothing, (xp flag keeps waving)
How to I find my .htacess if I need to edit it?

You can only access it with FTP, really. I use Crimson Editor
<http://www.crimsoneditor.com/> to do most uploading and editing. If your
FTP program isn't working try that. It's a free download.

When you FTP in you should see all the files in your main directory,
..htaccess should be there. If not, you should be able to create it with CE.
 
L

Lloyd

I got it working, I was calling error.html and had error.htm (missing 'l'),
I still can't find the .htaccess file, does it become hidden on the server
directory?
Thanks
 
D

Dylan Parry

Lloyd said:
I still can't find the .htaccess file, does it become hidden on the server
directory?

Yes, the "." in the filename is a Unix convention for specifying that a
file should be hidden. You should be able to find a setting somewhere in
your FTP client that allows you to see hidden files though.
 
R

Richard

Lloyd said:
Is there a way to change what a person sees on my site when they type in,
or get a bad url?
I see this:
The page cannot be found
On other sites I see different messages, I would like to customise mine.
Thanks in advance,
Lloyd

Ask your host how to proceed with customizable 404 pages before doing it on
your own.
 
J

Jukka K. Korpela

Lloyd said:
Is there a way to change what a person sees on my site when they
type in,
or get a bad url?

Probably. Others have already discussed the technicalities.
On other sites I see different messages, I would like to customise
mine.

While that's understandable, and recommended by useability experts, it
is _very_ easy to go wrong and create an error page that is _worse_
than the default one, at least for a large number of potential users.
A common error (when the pages are not in English) is to include the
error message in the language of the pages _only_.

So make sure you are making an improvement, so that the error page is
more understandable and more informative. For some notes see
http://www.cs.tut.fi/~jkorpela/www/404.html
 
N

Neal

.oO(Neal)


Should be

ErrorDocument 404 /error.html

Using an absolute URL for error documents will overwrite the original
status code and send a 302 redirect back to the client. Not really what
you want.

Thanks, but confused. I know it will forward to the file OK, I have it set
up that way on a site and have never had an issue to my knowledge. But
explain again on the 302 bit. Pretend I am dumber than I actually am ;)
 
M

Michael Fesser

.oO(Neal)
Thanks, but confused. I know it will forward to the file OK, I have it set
up that way on a site and have never had an issue to my knowledge. But
explain again on the 302 bit. Pretend I am dumber than I actually am ;)

If there's an error then it should be clearly stated as such to the user
agent, i.e. the server should respond with the correct error code. A
proper description of the current situation allows the user agent to
react accordingly, for example to remove the page in question from his
cache or index if its not available anymore.

But if the server responds with a redirect instead, it's more or less
like "OK, document found." There's no indication that an error occured
anymore, the user agent will believe that the address is still valid.

This becomes even more important and a real problem when doing HTTP
authentication, where the status 401 ("Unauthorized") is involved. An
absolute URL in the definition of the error document will break the
authentication mechanism, because now the browser won't receive the
original 401 status code and therefore won't show the login dialog.

Micha
 
J

Jukka K. Korpela

Neal said:
Thanks, but confused. I know it will forward to the file OK, I have
it set up that way on a site and have never had an issue to my
knowledge. But explain again on the 302 bit. Pretend I am dumber
than I actually am ;)

May I?

The status code (return code) is the server's primary way of telling
the browser (or other client) about the success of the request to get a
document at a specific URL. It may be accompanied with an actual
document, such as an HTML document, which could be the one the user
really wanted, or an explanation accompanying a status code that
indicates an error.

Normal processing of "not found" errors means that the server returns
code 404 and possibly an accompanying explanation. What you want is to
make sure the accompanying explanation is one that you wrote, instead
of the server's default.

What's wrong with Apache's behavior of sending the status code 302
(when an absolute URL is specified) is that it would indicate that the
original URL (in the request, e.g. as typed by the user or as written
into a link he followed) _works_ and the requested resource exists but
temporarily resides under a different URL! This would cause quite a lot
of confusion among users, search engines, etc.

For example, suppose you have created a Web page and you wish to use a
link checker (such as the one at w3c.org) to verify that all of your
links work in some technical sense at least. If you have actually
mistyped a link, the link checker will note a status code of 404 as an
error, so that you can fix the problem. But if the status code is 302,
there is no error to be reported; the checker could at most issue an
informative message about redirection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top