Categories
SEO Tips

How to implement 301 redirect: using WordPress redirection plugin, htaccess file or php code

You can implement “301 redirect” using several ways. I am sharing some simple and most widely used methods to create “301 redirect“.

301 redirect using WordPress Redirection Plugin

Redirection” is wordpress plugin which makes your “301 redirect” task simple and it doesn’t require knowledge of “.htaccess” file or PHP.

To use this plugin is very easy, you have to provide your old URL and New URL and it will create a “301 redirect” entry for you.

It not only creates the “301 redirect” but it takes care of all broken links as well.

301 redirect using .htaccess file

You must have access to your server .htaccess file or alternatively you can ask for access to your webhosting provider.

Moving a page
Redirect 301 /oldpage.html http://www.yourdomain.com/newpage.html Redirect 301 /oldpage2.html http://www.yoursite.com/folder/

Moving a directory
redirect 301 /old-directory http://www.newdomain.com/newdirectory

Moving an entire site
redirect 301 / http://www.newdomain.com/

301 redirect using PHP code

Moving a page in PHP
<?php
header(“Status: 301 Moved Permanently”, false, 301);
header(“Location: http://www.newdomain.com/newdirectory/newfilename.html”);
exit();
?>

There other ways as well like ‘creating rule’ but they require advance level of PHP and htaccess file knowledge.