I was planning on using a new domain name when migrating my legacy site to Drupal. I already have the php script that will translate old urls into Drupal Urls (I'm not using pathauto for that).

Now there is a chance I have to keep showing content on the old domain (mainly for SEO purposes). This site won't have any login or write-backs at all, it basically just shows the content and link to the new site.

How would I intercept the 404's that Drupal would now generate, preferably at a very low bootstrap level since there could be tons of invalid requests?


Sounds like I could use hook_boot() to intercept every page request early and then have the query string parsed and redirected to the matching node/... page on the same site.

Or, similar to Fast404 I could add an include_once to settings.php and do the redirect there:


Will there be a big difference between those two options?

  • Do you know drupal.org/project/path_redirect and drupal.org/project/redirect? They're the best solution to what you're trying to do. Commented Mar 12, 2012 at 14:26
  • 2
    path_redirect is 6 only - OP is using 7. Also, I think redirect is called later in the bootstrap process, whereas @MotoTribe wants to intercept it as early as possible.
    – Chapabu
    Commented Mar 13, 2012 at 9:15
  • If I correctly understood, there is content that is still shown from the legacy site, and Drupal needs to redirect to that; if that is the case, may you shown an example of URL that should be redirected to the legacy site? It is to understand if it is possible to make a string comparison, or it is required to call some Drupal function, including functions exposed from third-party modules.
    – apaderno
    Commented Mar 15, 2012 at 16:53

2 Answers 2


You could just use the Fast404 module (if I'm understanding your question correctly).

Drupal has expensive 404 errors. On an 'average' site with an 'average' module load, you can be looking at 60-100MB of memory being consumed on your server to deliver a 404. Consider a page with a bad .gif link and a missing .css file. That page will generate 2 404s along with the actual load of the page. You are most likely looking at 180MB of memory to server that page rather than the 60MB it should take.

That's where Fast 404 comes in. This module combines a very common method of handling missing image/file 404 errors (discussed here and planned for Drupal 8) with a method created by dpardo (a co-maintainer of this project) to deliver super fast 404 error pages for both missing images and bad paths. Depending on which method of implementation you choose (aggressive or super aggressive) you can deliver 404 errors using less than 1MB of memory on your server.

function YOUR_MODULE_NAME_init() {
  if(!menu_get_item($_GET['q'])) {
    //do whatever you want if page not found
  • thanks, I think hook_boot() would work in my case since it would happen earlier in the bootstrap process.
    – uwe
    Commented Mar 10, 2012 at 22:07
  • 4
    @MotoTribe menu_get_item() would not be accessible from hook_boot().
    – apaderno
    Commented Mar 15, 2012 at 16:42

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.