รับทำเว็บไซต์ครบวงจร
เลือกภาษา Thai English     facebook
รายการหลัก



บทความ


Page Ranking Tool

URL RewriteRule-error pages


สอน SEO
> URL RewriteRule-error pages


The default “Not found” page is ugly, isn’t it? Let’s personalize it, and along with it the other page you may need. If we refer to Hypertext Transfer Protocol - HTTP/1.1 RFC 2616 Chapter 10 “Status Code Definitions” (www.w3.org), paragraph 10.4 “Client Error 4xx” and 10.5 “Server Error 5xx”, you would need pages for the following situations:

  • 400 Bad Request (The request could not be understood by the server due to malformed syntax)
  • 401 Unauthorized (The request requires user authentication.)
  • 402 Payment Required (This code is reserved for future use.)
  • 403 Forbidden (The server understood the request, but is refusing to fulfill it.)
  • 404 Not Found (The server has not found anything matching the Request-URI.)
  • 405 Method Not Allowed (The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.)
  • 406 Not Acceptable (The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.)
  • 407 Proxy Authentication Required (This code is similar to 401 (Unauthorized), but indicates that the client must first authenticate itself with the proxy.)
  • 408 Request Timeout (The client did not produce a request within the time that the server was prepared to wait.)
  • 409 Conflict (The request could not be completed due to a conflict with the current state of the resource.)
  • 410 Gone (The requested resource is no longer available at the server and no forwarding address is known.)
  • 411 Length Required (The server refuses to accept the request without a defined Content- Length.)
  • 412 Precondition Failed (The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.)
  • 413 Request Entity Too Large (The server is refusing to process a request because the request entity is larger than the server is willing or able to process.)
  • 414 Request-URI Too Long (The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret.)
  • 416 Requested Range Not Satisfiable (The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.)
  • 417 Expectation Failed (A server SHOULD return a response with this status code if a request included a Range request-header field (See section 14.35), and none of the range-specifier values in this field overlap the current extent of the selected resource, and the request did not include an If-Range request-header field.)
  • 500 Internal Server Error (The server encountered an unexpected condition which prevented it from fulfilling the request.)
  • 501 Not Implemented (The server does not support the functionality required to fulfill the request.)
  • 502 Bad Gateway (The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.)
  • 503 Service Unavailable (The server is currently unable to handle the request due to a temporary overloading or maintenance of the server.)
  • 504 Gateway Timeout (The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.)
  • 505 HTTP Version Not Supported (The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.)

I needed only the following ones, but you may need some others depending on your site:

Now, you just have to create them, naming them through their message numbers, chart them and store them as any regular page somewhere on your site, in a designed-for directory, for instance, and add these lines to your “.htaccess” file, replacing of course “mypath/mydirectory” by your own:

ErrorDocument 400 /mypath/mydirectory/400.html ErrorDocument 401 /mypath/mydirectory/401.html ErrorDocument 403 /mypath/mydirectory/403.html ErrorDocument 404 /mypath/mydirectory/404.html ErrorDocument 405 /mypath/mydirectory/405.html ErrorDocument 500 /mypath/mydirectory/500.html

Here are my corresponding lines in my “.htaccess” file:

################################################################################ # Error pages # To use it on EasyPHP, remember to add up the site's folder on each line. # For instance :  # ErrorDocument 404 /www.html4.com/mime/markup/html/error_pages/404.php #------------------------------------------------------------------------------- ErrorDocument 400 /mime/markup/html/error_pages/400.php ErrorDocument 401 /mime/markup/html/error_pages/401.php ErrorDocument 403 /mime/markup/html/error_pages/403.php ErrorDocument 404 /mime/markup/html/error_pages/404.php ErrorDocument 405 /mime/markup/html/error_pages/405.php ErrorDocument 500 /mime/markup/html/error_pages/500.html ################################################################################

The “method not allowed” page is a PHP page for it sends me a mail any time it is triggered. It generally signals an attempt to use the “PUT” or “POST” method by an unwanted dumbass.

NOTA: Some will advise you NOT TO design a custom error 500 page, for it’s due to serious error, and that you should not ask the server to handle them your way. Well, as there are three different examples of error 500 handling on the reference page Apache HTTP Server - Custom error responses, do as you please.

IMPORTANT: Check your connnection logs for error messages. A good site will suffer from any “404 Not found” or “410 Gone”. The average custommer will flee. Robots will lower the page ranking.

IMPORTANT: The HTTP/1.0 protocol will only support this error codes :

  1. 400 Bad Request
  2. 401 Unauthorized
  3. 403 Forbidden
  4. 404 Not Found

Please refer to Hypertext Transfer Protocol - HTTP/1.0 chapter 9.4 “Client Error 4xx”. Here is a really interesting post about the “410 Gone” error code (webmasterworld.com’s forum).



Short URL click!
<< กลับคืน : เข้าชม 6,156 ครั้ง : ขึ้นไปด้านบน

รับทำเว็บไซต์ รับสร้างเว็บไซต์ รับออกแบบเว็บ รับเขียนเว็บ รับสอนทำเว็บ รับเช่า hosting รับเช่าพื้นที่เว็บไซต์ จดชื่อเว็บ รับโปรโมทเว็บไซต์ รับดูแลเว็บ SiteMap
สปริงเกอร์http://www.xn--22c2c4blb9n.xn--o3cw4h/