Redirect 404 to Homepage using Htaccess

Redirect 404

Using Htaccess

ErrorDocument 404 /404.php

WordPress Sites

Replace the content of 404.php, which is located in /wp-content/themes/theme-name/ to the following code:

<?
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.example.com/” );
?>

Note:

Same rule applies to other error codes mentioned below:

Client Request Errors

  • 400 Bad Request
  • 401 Authorization Required
  • 402 Payment Required (not used yet)
  • 403 Forbidden
  • 404 Not Found
  • 405 Method Not Allowed
  • 406 Not Acceptable (encoding)
  • 407 Proxy Authentication Required
  • 408 Request Timed Out
  • 409 Conflicting Request
  • 410 Gone
  • 411 Content Length Required
  • 412 Precondition Failed
  • 413 Request Entity Too Long
  • 414 Request URI Too Long
  • 415 Unsupported Media Type

Server Errors

  • 500 Internal Server Error
  • 501 Not Implemented
  • 502 Bad Gateway
  • 503 Service Unavailable
  • 504 Gateway Timeout
  • 505 HTTP Version Not Supported
Client Request Errors
400Bad Request
401Authorization Required
402Payment Required (not used yet)
403Forbidden
404Not Found
405Method Not Allowed
406Not Acceptable (encoding)
407Proxy Authentication Required
408Request Timed Out
409Conflicting Request
410Gone
411Content Length Required
412Precondition Failed
413Request Entity Too Long
414Request URI Too Long
415Unsupported Media Type
Server Errors
500Internal Server Error
501Not Implemented
502Bad Gateway
503Service Unavailable
504Gateway Timeout
505HTTP Version Not Supported

Leave a comment

Your email address will not be published. Required fields are marked *