403 和 404 错误页面 Drupal 7

403 and 404 error pages Drupal 7

function multipurpose_zymphonies_theme_preprocess_page(&$vars) {
 $header = drupal_get_http_header("status");
  if ($header == "404 Not Found") {
    $vars['theme_hook_suggestions'][] = 'page__404';
  }
  elseif ($header == "403 Forbidden") {
    $vars['theme_hook_suggestions'][] = 'page__403';
  }
  }

I am using this above code to redirect the 404 and 403 to custom pages but

nothing happens. I have created two files: page--404.tpl.php and page--403.tpl.php in my theme templates folder

如果我只是在 url 中写下“http://example.com/readme" then its show 404 which is custommize by me but when i write like "http://example.com/readme.txt”,那么它就会显示

Not Found The requested URL "/readme.txt" was not found on this server.

以及其他错误禁止访问,当我在 url 中写入时,如“http://example.com/%7C~.aspx

Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster. Error 403

我想处理自定义页面的所有这些错误

您可以通过 url 中的配置来配置默认错误页面:

yoursite/admin/config/system/site-information

管理 > 配置 > 系统 > 站点信息