WordPress

How to redirect 404 to homepage in wordpress

Rate this post

Want to redirect 404 error page to your homepage in wordpress? Here is how

Login to your wordpress admin page http://website.com/wp-admin/
Go to “Apperarance” -> “Editor” -> 404.php

If your theme doesnt have 404.php page, create one under your theme directory wp-content/themes/themename/

Change or create your 404.php code to these

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit(); ?>

What those code does is to tell browswer that page has moved permantly with 301 error code, then redirect to your home page.

Tags

Related Articles

Leave a Reply

avatar
Photo and Image Files
 
 
 
Audio and Video Files
 
 
 
Other File Types
 
 
 

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of
Back to top button
Close

Send this to a friend