4

Under Site Information we can provide custom 404 and 403 pages to Drupal, but these need to be created inside Drupal, and non Drupal pages are rejected. (such as myerror/404.html).

Contrib modules like custom error and static 404 also work inside Drupal. Any ideas on how to set an external page as 404 or 403?

2
  • Any particular reason for using HTML ? Cant you put the contents of that HTML in a node and use that node for 404 ?
    – GoodSp33d
    Commented May 24, 2013 at 9:59
  • The design of the html is somewhat complex and different to the site. Also, this is a multilingual site, so we would need to do this for every language. Also, Drupal is just a small part of the site at the moment :)
    – giorgio79
    Commented May 24, 2013 at 10:04

2 Answers 2

5

If you want to catch errors not handled by Drupal, you can do this using .htaccess:

ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html
ErrorDocument 500 /error500.html

However, if you want to intercept the errors handled by Drupal, and redirect that to an standalone error page, you should be able to do this with Redirect 404.

1
  • Note that Redirect 404 does NOT send actual 404 HTTP header. For SEO purposes it will not be a 404, but a massive case of duplicated content, if you will use it to redirect to static page. It may kill your site's position in search results.
    – Mołot
    Commented May 24, 2013 at 10:48
3

When sending 404 or 403 header, Drupal cannot use redirect, as redirects are simply 3xx headers and you want 4xx. So, if it cannot redirect, it needs to pass the body of a file itself. But for security reasons it cannot access files outside it's own installation directory.

There are 3 solutions:

  1. Use iframe, JavaScript, or other client-side technique to provide content from outside Drupal directory
  2. Use webserwer's built in capabilities to substitute Drupal-generated response body with a content of outside file
  3. Provide a filesystem links to files you need

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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