| 1. |
How To Define Custom Error Pages Using .htaccess? |
|
Answer» You can define your own error pages to improve the communication with your visitors in CASE something´s wrong with your site or if they are TRYING to access pages that are no longer available. Simply create a webpage for each of the error codes you like. Here are some of the most common errors: 401 – Authorization REQUIRED – occurs when users try to access password protected pages without giving the correct credentials. 403 – Forbidden – occurs when users try to access a file (web document, script, graphic, etc …) whose file permissions do not allow the requested action (execute / READ / write). 404 – Not Found – occurs when users try to access a webpage that doesn´t exist on your site. 500 – Internal Server Error. You can name these custom error pages anything you like, but I recommend you choose file names that remind you of the function of each document (f.ex. notfound.html or 404.html for the 404 error page) and you can store them in any location on your server that has web access (either your root directory or a subdirectory). Then you can define these pages as custom error pages in your .htaccess file. Supposing you have named your error pages 401.html, 404.html and 500.html and stored them in your website´s root directory, then you would add these lines to your .htaccess file: ErrorDocument 401 /401.html ErrorDocument 404 /404.html ErrorDocument 500 /500.html If you have named these pages “notfound.html”, “authorization.html” and “internalerror.html” and UPLOADED them to a subdirectory named “errorpages”, you would add this to your .htaccess file: ErrorDocument 401 /errorpages/authorization.html ErrorDocument 404 /errorpages/notfound.html ErrorDocument 500 /errorpages/internalerror.html You can define your own error pages to improve the communication with your visitors in case something´s wrong with your site or if they are trying to access pages that are no longer available. Simply create a webpage for each of the error codes you like. Here are some of the most common errors: 401 – Authorization Required – occurs when users try to access password protected pages without giving the correct credentials. 403 – Forbidden – occurs when users try to access a file (web document, script, graphic, etc …) whose file permissions do not allow the requested action (execute / read / write). 404 – Not Found – occurs when users try to access a webpage that doesn´t exist on your site. 500 – Internal Server Error. You can name these custom error pages anything you like, but I recommend you choose file names that remind you of the function of each document (f.ex. notfound.html or 404.html for the 404 error page) and you can store them in any location on your server that has web access (either your root directory or a subdirectory). Then you can define these pages as custom error pages in your .htaccess file. Supposing you have named your error pages 401.html, 404.html and 500.html and stored them in your website´s root directory, then you would add these lines to your .htaccess file: ErrorDocument 401 /401.html ErrorDocument 404 /404.html ErrorDocument 500 /500.html If you have named these pages “notfound.html”, “authorization.html” and “internalerror.html” and uploaded them to a subdirectory named “errorpages”, you would add this to your .htaccess file: ErrorDocument 401 /errorpages/authorization.html ErrorDocument 404 /errorpages/notfound.html ErrorDocument 500 /errorpages/internalerror.html |
|