404 error file

T

thedarkman

I want to create one of these so that in the event of a broken link the user gets a message like here

http://www.digitaljournal.com/article/360991

redirecting to the Internet Archive.

I read up on the .htaccess file but creating one of those simply makes my directories disappear. I can't find a simple one either. Can anyone point me in the right direction?

Thanks
 
C

Christoph Michael Becker

thedarkman said:
I want to create one of these so that in the event of a broken link
the user gets a message like here

http://www.digitaljournal.com/article/360991

redirecting to the Internet Archive.

I read up on the .htaccess file but creating one of those simply
makes my directories disappear. I can't find a simple one either. Can
anyone point me in the right direction?

You're probably looking for the ErrorDocument directive[1].

[1] <http://httpd.apache.org/docs/2.2/mod/core.html#errordocument>
 
T

thedarkman

This is a very long document and I can't make much sense of it. I want to create a htaccess file and an error file for the site. All I need is a brief bit of code for both. Also what do I call the error file? error.html?

Thanks
 
D

Denis McMahon

I read up on the .htaccess file but creating one of those simply makes
my directories disappear. I can't find a simple one either. Can anyone
point me in the right direction?

In theory, the following single line in an .htaccess file should work:

ErrorDocument 404 http://archive.org/

However this does rely upon the server configuration (probably controlled
by your hosting provider) allowing you to use this directive in
an .htaccess file.

If you want to specify a document on your own website, use:

ErrorDocument 404 /path/to/file.text

where the /path/to/file.ext is relative to the root of the website.

eg if the full url is:

http://www.domain.tld/path/to/file.ext

Then use:

ErrorDocument 404 /path/to/file.ext

but if the full url is

http://www.domain.tld/bing/bang/bong/file.ext

Then use:

ErrorDocument 404 /bing/bang/bong/file.ext

Note that ext should probably be something that the server associates
with web content, ideally .[x]htm[l] or .php etc, and also note that if
you screw it up, all sorts of weird shit happens.
 
O

odemgoldenslippers

Hi,

the code you recommended works; I put it in the .htaccess file, and entering a bad url takes it straight to the Internet Archive. What I would really like to do though is get it to display the message on this page:
http://blog.archive.org/2013/10/24/web-archive-404-handler-for-webmasters/

they give the following code for the error file:
<div id="wb404"/>
<script src="https://archive.org/web/wb404.js"> </script>

this does not seem to work.

Can you give it one more try so I can display the message?

Thanks
 
D

Denis McMahon

Hi,

the code you recommended works; I put it in the .htaccess file, and
entering a bad url takes it straight to the Internet Archive. What I
would really like to do though is get it to display the message on this
page:
http://blog.archive.org/2013/10/24/web-archive-404-handler-for- webmasters/

they give the following code for the error file:
<div id="wb404"/>
<script src="https://archive.org/web/wb404.js"> </script>

this does not seem to work.

Can you give it one more try so I can display the message?

You need to create your own 404 error page, point the ErrorDocument 404
at your error page, and include their code in your error page.

Note that in order for this to work, your error page has to be dtd valid
xhtml, and if you're who I think you are, that means you're probably
stuffed, because the person I associate the OP with has for years been
insisting on forcing broken html 1/2/3/4 tag soup into browsers to the
point that they run out of memory trying to map his broken interleaved
elements into a dom, and probably couldn't write valid xhtml to save his
life.

Of course, I may be making the wrong association, and you may not be a
nymshift of the OP.
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top