You are here

README.txt in Customerror 6

Same filename and directory in other branches
  1. 8 README.txt
  2. 5 README.txt
  3. 7 README.txt
CUSTOM ERROR README.txt
=======================

This module allows the site admin to create custom error pages for
HTTP status codes 403 (access denied) and 404 (not found), without the
need to create nodes for each of them.

Main features:

* Configurable page title and descriptions.
* There are no author and date/time headers as with normal nodes.
* Any HTML formatted text can be be put in the page body.
* The error pages are themeable.
* Users who are not logged in and try to access an area that requires
  login will be redirected to the page they were trying to access after
  they login.
* Allows custom redirects for 404s.

Since the error pages are not real nodes, they do not have a specific
content type, and will not show up in node listings.

At present, the module can be set up to handle 403 and 404
errors. Drupal only allows those two errors to be assigned custom
pages. However, the design of the module is flexible and can
accommodate future error codes easily.


Installation:
-------------

1. Install the customerror module directory in the directory where you
   keep contributed modules (e.g. sites/all/modules/).

2. Go to the Modules page
   - Enable the customerror module.
   - If you want to messages to contain PHP, enable the core
     PHP filter module.
   Click on Save configuration.

3. Configure Error reporting
   - Go to Administer -> Site configuration -> Error reporting
   - For 403 (access denied), enter the value:
       customerror/403
   - For 404 (not found), enter the value:
       customerror/404
   Click on Save configuration.

4. Configure the module:
   - Go to Administer -> Site configuration -> Custom error
   - Enter any title and description you want for the 404 (not found)
     and 403 (access denied) pages.
   - You can use any HTML tags to format the text.
   Click on Save configuration.

5. Test your error pages.
   - Copy your present admin page url.
   - Try to go to a non-existent Drupal page on your site.
   You should see your custom error page for 404 (not found) page.

   - Log out from your site.
   - Paste the admin page url and try to go there.
   You should see your custom error page for 403 (access denied) page.


Redirecting upon login
----------------------

Here is an example of how to add custom PHP to a 403 to give the user
the option to login:

<?php
global $user;
if ($user->uid == 0) {
  $output = '<p>';
  $output .= t('If your user account has access to this page, please !message.',
    array(
      '!message' => l(t('log in'), 'user'),
    )
  );
  $output .= '</p>';
  print $output;
}
?>

Note that customerror keeps track of what page the user is trying to
access, so after logging in, the user will be redirected to that page.


Theme to be used on the error page
----------------------------------

If you've set an administration theme, the default is to use this on
all pages where the path is "admin", including 403 and 404 error
pages.  You can overide this by specifying a theme for custom error
different from "System default".

This setting has no effect if the administration theme is set to
"<System default>".


Custom redirects for 404 errors
-------------------------------

It is possible to set up custom redirects for status code 404 (not
found).

For example if you had a page called foo and a page called xyz, then
you moved them to a page called bar, and abc respectively, you can
setup a redirect pair of:

  ^foo$ bar
  ^xyz$ abc

The first pair will transparently redirect users trying to access
example.com/foo to example.com/bar.  The second pair will
transparently redirect users trying to access example.com/xyz to
example.com/abc.

You can have multiple pairs of redirects. Each must be on a line by
itself.

Note that the first argument is a regexp, and the second argument is a
path. You have to use one space between them, and enter each pattern
on a line by itself. You cannot use variables.

For more flexible URL rewriting, including variables, you may consider
using an external URL rewrite engine, such as Apache mod_rewrite.


FAQ
---

* I want to prevent robots from indexing my custom error pages by
  setting the robots meta tag in the HTML head to NOINDEX.

  - There is no need to. CustomError returns the correct HTTP status
    codes (403 and 404). This will prevent robots from indexing the
    error pages.
	
* I want to customize the custom error template output.

  - In your site's theme, duplicate your page.tpl.php to be 
    page-customerror.tpl.php and then make your modifications there.

* I want to have a different template for my 404 and 403 pages.

  - Duplicate your page.tpl.php page to be page-customerror-404.tpl.php 
    and page-customerror-403.tpl.php. You do not need a 
    page-customerror.tpl.php for this to work.

* Some 403 errors (e.g. "http://example.org/includes") are served by
  the Apache web server and not by CustomError. Isn't that a bug?

  - No. CustomError is only designed to provide a custom error page
    when the page is processed by Drupal.  The .htaccess file that
    comes with Drupal will catch some attempts to access forbidden
    directories before Drupal even see the requests.  These access
    attempts will get the default Apache 403 error document, unless
    you use the Apache ErrorDocument directive to override this, e.g:
      ErrorDocument 403 /error/403.html
    For more information about this, see:
    http://httpd.apache.org/docs/current/custom-error.html

* How can I get blocks to appear on the custom 403 and 404 pages?

  - Blocks will not appear on the custom 403 and 404 pages produced by
    this module.  If you want the blocks shown, either upgrade to the
    Drupal 7 version, or use the "404 Blocks" module as a workaround.

    URLs:
      https://drupal.org/node/709298
      https://drupal.org/project/blocks404


Database
--------

This module does not require any new database tables to be installed.


Bugs/Features/Patches
---------------------

If you want to report a bug, request a feature, or submit a patch,
please do so in the issue queue at the project page on the Drupal web
site:

   http://drupal.org/project/customerror


Online documentation
--------------------

For more documentation, please see:

   https://drupal.org/node/2064843

Author
------

Principal author is Khalid Baheyeldin
(http://baheyeldin.com/khalid and http://2bits.com).

Auxiliary maintainer is Gisle Hannemyr
(https://drupal.org/user/409554).

The authors can be contacted for paid customizations of this module
as well as Drupal consulting, installation, development, and
customizations.

File

README.txt
View source
  1. CUSTOM ERROR README.txt
  2. =======================
  3. This module allows the site admin to create custom error pages for
  4. HTTP status codes 403 (access denied) and 404 (not found), without the
  5. need to create nodes for each of them.
  6. Main features:
  7. * Configurable page title and descriptions.
  8. * There are no author and date/time headers as with normal nodes.
  9. * Any HTML formatted text can be be put in the page body.
  10. * The error pages are themeable.
  11. * Users who are not logged in and try to access an area that requires
  12. login will be redirected to the page they were trying to access after
  13. they login.
  14. * Allows custom redirects for 404s.
  15. Since the error pages are not real nodes, they do not have a specific
  16. content type, and will not show up in node listings.
  17. At present, the module can be set up to handle 403 and 404
  18. errors. Drupal only allows those two errors to be assigned custom
  19. pages. However, the design of the module is flexible and can
  20. accommodate future error codes easily.
  21. Installation:
  22. -------------
  23. 1. Install the customerror module directory in the directory where you
  24. keep contributed modules (e.g. sites/all/modules/).
  25. 2. Go to the Modules page
  26. - Enable the customerror module.
  27. - If you want to messages to contain PHP, enable the core
  28. PHP filter module.
  29. Click on Save configuration.
  30. 3. Configure Error reporting
  31. - Go to Administer -> Site configuration -> Error reporting
  32. - For 403 (access denied), enter the value:
  33. customerror/403
  34. - For 404 (not found), enter the value:
  35. customerror/404
  36. Click on Save configuration.
  37. 4. Configure the module:
  38. - Go to Administer -> Site configuration -> Custom error
  39. - Enter any title and description you want for the 404 (not found)
  40. and 403 (access denied) pages.
  41. - You can use any HTML tags to format the text.
  42. Click on Save configuration.
  43. 5. Test your error pages.
  44. - Copy your present admin page url.
  45. - Try to go to a non-existent Drupal page on your site.
  46. You should see your custom error page for 404 (not found) page.
  47. - Log out from your site.
  48. - Paste the admin page url and try to go there.
  49. You should see your custom error page for 403 (access denied) page.
  50. Redirecting upon login
  51. ----------------------
  52. Here is an example of how to add custom PHP to a 403 to give the user
  53. the option to login:
  54. global $user;
  55. if ($user->uid == 0) {
  56. $output = '

    ';

  57. $output .= t('If your user account has access to this page, please !message.',
  58. array(
  59. '!message' => l(t('log in'), 'user'),
  60. )
  61. );
  62. $output .= '

    ';
  63. print $output;
  64. }
  65. ?>
  66. Note that customerror keeps track of what page the user is trying to
  67. access, so after logging in, the user will be redirected to that page.
  68. Theme to be used on the error page
  69. ----------------------------------
  70. If you've set an administration theme, the default is to use this on
  71. all pages where the path is "admin", including 403 and 404 error
  72. pages. You can overide this by specifying a theme for custom error
  73. different from "System default".
  74. This setting has no effect if the administration theme is set to
  75. "".
  76. Custom redirects for 404 errors
  77. -------------------------------
  78. It is possible to set up custom redirects for status code 404 (not
  79. found).
  80. For example if you had a page called foo and a page called xyz, then
  81. you moved them to a page called bar, and abc respectively, you can
  82. setup a redirect pair of:
  83. ^foo$ bar
  84. ^xyz$ abc
  85. The first pair will transparently redirect users trying to access
  86. example.com/foo to example.com/bar. The second pair will
  87. transparently redirect users trying to access example.com/xyz to
  88. example.com/abc.
  89. You can have multiple pairs of redirects. Each must be on a line by
  90. itself.
  91. Note that the first argument is a regexp, and the second argument is a
  92. path. You have to use one space between them, and enter each pattern
  93. on a line by itself. You cannot use variables.
  94. For more flexible URL rewriting, including variables, you may consider
  95. using an external URL rewrite engine, such as Apache mod_rewrite.
  96. FAQ
  97. ---
  98. * I want to prevent robots from indexing my custom error pages by
  99. setting the robots meta tag in the HTML head to NOINDEX.
  100. - There is no need to. CustomError returns the correct HTTP status
  101. codes (403 and 404). This will prevent robots from indexing the
  102. error pages.
  103. * I want to customize the custom error template output.
  104. - In your site's theme, duplicate your page.tpl.php to be
  105. page-customerror.tpl.php and then make your modifications there.
  106. * I want to have a different template for my 404 and 403 pages.
  107. - Duplicate your page.tpl.php page to be page-customerror-404.tpl.php
  108. and page-customerror-403.tpl.php. You do not need a
  109. page-customerror.tpl.php for this to work.
  110. * Some 403 errors (e.g. "http://example.org/includes") are served by
  111. the Apache web server and not by CustomError. Isn't that a bug?
  112. - No. CustomError is only designed to provide a custom error page
  113. when the page is processed by Drupal. The .htaccess file that
  114. comes with Drupal will catch some attempts to access forbidden
  115. directories before Drupal even see the requests. These access
  116. attempts will get the default Apache 403 error document, unless
  117. you use the Apache ErrorDocument directive to override this, e.g:
  118. ErrorDocument 403 /error/403.html
  119. For more information about this, see:
  120. http://httpd.apache.org/docs/current/custom-error.html
  121. * How can I get blocks to appear on the custom 403 and 404 pages?
  122. - Blocks will not appear on the custom 403 and 404 pages produced by
  123. this module. If you want the blocks shown, either upgrade to the
  124. Drupal 7 version, or use the "404 Blocks" module as a workaround.
  125. URLs:
  126. https://drupal.org/node/709298
  127. https://drupal.org/project/blocks404
  128. Database
  129. --------
  130. This module does not require any new database tables to be installed.
  131. Bugs/Features/Patches
  132. ---------------------
  133. If you want to report a bug, request a feature, or submit a patch,
  134. please do so in the issue queue at the project page on the Drupal web
  135. site:
  136. http://drupal.org/project/customerror
  137. Online documentation
  138. --------------------
  139. For more documentation, please see:
  140. https://drupal.org/node/2064843
  141. Author
  142. ------
  143. Principal author is Khalid Baheyeldin
  144. (http://baheyeldin.com/khalid and http://2bits.com).
  145. Auxiliary maintainer is Gisle Hannemyr
  146. (https://drupal.org/user/409554).
  147. The authors can be contacted for paid customizations of this module
  148. as well as Drupal consulting, installation, development, and
  149. customizations.