I want to redirect all 404 errors on my site to the same path on a different server.

For example:

http://drupal.example.com/url/not/in/drupal should be redirected to http://othersite.example.com/url/not/in/drupal

The sites are not on the same server and the other site is not running Drupal.

I know I can use the redirect module to redirect specific URLs but I don't have a complete list of the URLs on the other site so building the list is not practical.

Suggestions for modules or pointers to the appropriate hooks if I want to write my own module would be appreciated.


Here is small trick:

Enable module PHP Filter, add PHP filter to administrator

Create a node can use php filter, add code: (We are using header here, not use drupal_goto because handle 404 workfollow of Drupal will redirect to the node first.

  $url = drupal_get_destination();
  header('Location: http://other.example.com/' . $url['destination']);

Config Drupal using 404 page is the node you was create.

  • 1
    This doesn't seem to handle parameters but it answers my question. I will probably re-implement your solution as a module because I don't want the php filter enabled on the site. – Craig Sep 21 '11 at 0:13
  • Having php filter enabled is generally considered poor practice and a security risk. – starsinmypockets Sep 21 '11 at 3:01
  • It is just the solution. @Craig need to write a module :). – Sang Le Thanh Sep 21 '11 at 14:09

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.