Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I think you have a problem understanding the HTTP protocol.

Imagine you knock on a door and ask for a photo of a certain teddy bear. This is a HTTP request. Now, you could get some different responses:

Human behind the doorStatus CodeStatus Text from RFC 2616Notes
"OK, here you are", and hands over a pretty image200OK
"Do you want a picture of it in the green shorts? Or with the new stylish jeans? Or in the fluffy dress? Or ..."300Multiple Choices
"Sorry, I gave the teddy to the son of my neighboor just over the street. Ask him."301Moved PermanentlyNote that you will never see the teddy bear here again.
"Hmm, let me think. Where did I put it? Hmmm... - Oh right, it's at the neighboor next door."302FoundNo information about how long the teddy bear will stay there.
"Walk around the house, I'll give it to you through the front door"303See OtherRFC: For redirects from POST to GET
"Oh, right, that teddy bear. My son has carried it into the basement, go there and ask him".307Temporary RedirectThe teddy will come back here.
"┐Hablas espa˝ol? Parlez-vous franšais? Sprechen Sie deutsch?"400Bad Request
"Let me see your ID card first, please"401Unauthorized
"Hand over the money first"402Payment RequiredNo, I'm not kidding. But as no one has a working concept for payments inside HTTP, the code description has changed to "reserved for future use".
"YOU, Sir, won't get that from me."403Forbidden
"I don't have no stinkin' bears."404Not FoundNot here, no information if it was here before or will be here later.
"The bear photographer? No, he doesn't live here any more. Don't know where he's gone."410GoneGone, and won't come back, like 301. But no new URL known, so no redirection.
***KABOOOOOM***500Internal Server Error
"Sorry, I don't have a polaroid."501Not Implemented
"My parents are not at home. Please come back later!"504Service Unavailable

Is it clear now?

What answer do you want to give? 404 means "I don't have that, and I don't know where it is." No Redirection. 301/302/303/307 means "OK, I don't have it here, but look over there." with minor differences in WHY you don't have the requested resource. Redirection follows automatically. Or the really hard 410? "It is no longer here, and it won't come back."

Why do you think that search engines or customers need a special treatment? If a resource is not available, send 404 or perhaps 410. If it is elsewhere, send 301/302/303/307.

If you want to help humans navigating your page when they hit a 404 page, you could add a search form, a link to a search page, a link to a site map, or links to the most wanted pages to the 404 page. Just make sure that the 404 page is larger than 1024 bytes, or else MS IE users will only see a braindead default page generated by the MS IE.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^3: Doing a proper 404 redirect by afoken
in thread Doing a proper 404 redirect by DreamT

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (7)
    As of 2014-09-22 12:39 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (191 votes), past polls