0

Drupal offers us the possibility to set the 404 page displayed for the end users (this can be set in the admin configuration).

Ex : If you type

http://www.example.com/doesntexist

you are redirected to

http://www.example.com/my-custom-404-page (alias for a node)

While this is a good approach for end users, what about the side effects for the Google bot ?

Generally speaking, if the Google Bot received a 404 error for a page, it will stop crawling it.

However, with the solution displayed above, the headers of the response page are :

HTTP/1.1 302 Found

So my question is : is there any way to have the 404 HTTP code while having a nice custom error page ?

  • 1
    Sadly true:( bot indexing that page. You can replace http header in a hook, eg. hook_node_view_alter(), if ($build['#node']->nid == your custom 404 page node ID) {, then drupal_add_http_header('HTTP/1.0', '404 Not Found'); – malcolm May 2 '13 at 10:38
  • I also like your hook idea. – Jean-Michel Garcia May 2 '13 at 12:49
3

Installing Custom Error will fix this problem.

I am using this module and I've set up custom 403 and 404 page for my site. Example: http://www.nemo-project.org/board/doesntexist - and it returns 404 according to http://www.seoconsultants.com/tools/headers

(I am not sure if this module is necessary to get the correct HTTP response codes, but it is a nifty module and does the job - I use it on all my Drupal 7 sites.)

  • Do you use it for Drupal 7 ? – Jean-Michel Garcia May 2 '13 at 12:43
  • No that obviously to me since I only worked with Drupal 7 :) Can't say what D6 looks like. – Jean-Michel Garcia May 2 '13 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.