Sometimes when you are surfing, you get a page with "The page can not be found". This is the default 404 error page, but you can also add your own error pages. In this instance, you can send them automatically to the index of your website if a page cannot be found, or if they don't have acces.
Note: This only works on Apache web servers!
The errors:
There are various error pages. The most common are the 404 when a page cannot be not found, and the 401 on when you don't have access to a page. Below is a list of all error pages out there and their meaning.
. Htaccess:
Creating a. Htaccess file is easy. Open notepad and create a file called htaccess.txt. Enter the following things:
And of course you have more error pages for the other errors out there. You just change the numbers.
You can also use instead of an html file for each error, a. Php file for any errors. You can do this this as follow:
.Htaccess:
In Error.php you put:
Then upload the file to your webserver and rename htaccess.txt to".Htaccess".
Testing error pages:
You should have your custom error pages now work. You can test this by typing in a wrong URL. So for example http://www.yourdomain.com/trololol.html. If all goes well it will show the error page by yourself.
Other servers:
If your server isn't running Apache you should look here.
They explain how to do this vor many other servers.
Note: This only works on Apache web servers!
The errors:
There are various error pages. The most common are the 404 when a page cannot be not found, and the 401 on when you don't have access to a page. Below is a list of all error pages out there and their meaning.
Code:
• 302 - Redirect
• 400 - Bad Request
• 401 - Authorization Required
• 402 - Payment Required
• 403 - Forbidden
• 404 - File Not Found
• 405 - Method Not Allowed
• 406 - Not Acceptable
• 407 - Proxy Authentication Required
• 408 - Request Timeout
• 409 - Conflict
• 410 - Gone
• 411 - Length Required
• 412 - Precondition Failed
• 413 - Request Entity Too Large
• 414 - Request-URI Too Large
• 415 - Unsupported Media Type
• 500 - Internal Server Error
• 501 - Method Not Implemented
• 502 - Bad Gateway
• 503 - Service Temporarily Unavailable
• 504 - Gateway Timeout
• 505 - HTTP Version Not Supported. Htaccess:
Creating a. Htaccess file is easy. Open notepad and create a file called htaccess.txt. Enter the following things:
Code:
ErrorDocument 404 / 404.html
ErrorDocument 401 / 401.html
ErrorDocument 403 / 403.html
ErrorDocument 500 / 500.htmlAnd of course you have more error pages for the other errors out there. You just change the numbers.
You can also use instead of an html file for each error, a. Php file for any errors. You can do this this as follow:
.Htaccess:
Code:
ErrorDocument 404 / error.php? page = 404
ErrorDocument 401 / error.php? page = 401
ErrorDocument 403 / error.php? page = 403
ErrorDocument 500 / error.php? page = 500In Error.php you put:
PHP Code:
<Phpif ($ _GET ['page']==" 404') {
echo "Error 404";
}
if ($ _GET ['page']==" 401 ") {
echo "error 401";
}
?>Then upload the file to your webserver and rename htaccess.txt to".Htaccess".
Testing error pages:
You should have your custom error pages now work. You can test this by typing in a wrong URL. So for example http://www.yourdomain.com/trololol.html. If all goes well it will show the error page by yourself.
Other servers:
If your server isn't running Apache you should look here.
They explain how to do this vor many other servers.


8:04 AM
Unknown
Posted in: 
0 comments:
Post a Comment