What is 301 redirect and How to implement it

lop9Today I’ll tell you, what is 301 redirect and why should you implement it on your website. If we see the definition, the 301 redirect is the permanent redirect from one url to another. For example, If you want to show your content at a new url then you have to implement 301 redirect so that when someone would type the old url, he/she will be redirected to the new one.

Case of http://www.yourwebsite.com and http://yourwebsite.com

Now consider you have a website named http://www.yourwebsite.com.

Ok, now if you are not using 301 redirect then the url http://www.yourwebsite.com and http://yourwebsite.com will be considered as different by search engines and all the inbound links that point to http://www.yourwebsite.com won’t pass authority over to http://yourwebsite.com and vice versa. Due to this, it can effect to website’s ranking and indexing. It is necessary to implement 301 redirect so that search engines see a single URL. Here the most important thing to consider is that it saves you from duplicate content.

When changing Permalink structure

If you are deciding to change your permalink structure then you need to 301 redirect the URLs. If you change your permalink structure without implementing 301 redirect, you will get a 404(file not found) error while opening your old URL.

Today the most preferred permalink structure is http://www.yourwebsite.com/%postname%/ as it is more seo friendly and many of you are using old permalink structure and want to change the it.

Best Permalink structure before WordPress 3.3:

  • /%postid%/%postname%/
  • /%year%/%postname%/

Best Permalink structure for WordPress 3.3 and later

  • /%postname%/
  • /%category%/%postname%/

Most used today

  • /%postname%/

Moving to a new Domain

If you are moving to a better and new domain then you can implement 301 redirect to your old URLs. By doing so, it will pass the SEO credits and inbound links of your old Domain URLs to the new one.


How to implement 301 Redirect

  • Moving a Domain Name

In this case you have to write or copy the following code in the top of your .htaccess file

redirect 301 / http://www.newwebsite.com/

  • Moving a new page in HTML

Redirect 301 /oldpage.html http://www.yourwebsite.com/newpage.html

  • Moving a new page in php

header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.New-Website.com”);

  • Change permalink structure using 301 redirect

There are two ways to change the permalink structure from old to new one.

  • Editing .htaccess file
  • By using plugin

If you are changing permalink structure to /%postname%/ then you should go with the first method otherwise the second method will be better.

1st Method

If you decide to go with/%postname%/ then follow the steps:

  • Download or backup the original copy of your .htaccess file. In case something goes wrong, you can re-upload it.
  • Now go to this page and click on the orange botton as shown in th pic below.
  •  Now a window will appear as shown below. Fill every column correctly and click on Generate redirect.
  • Now you will get a code. Copy this and paste it on the top of your .htaccess file.
  • Now go to wordpress dashboard and change your permalink structure to /%postname%/ or http://www.yourwebsite.com/sample-post/.
  • You are done now. Now try to open an old link to see if it is working. You can use a 301 redirect checker to check your old URL.

2nd Method 

You can use the Redirection plugin. Just install the plugin before changing your permalinks. This plugin automatically 301 redirects URL changes.

If you have any problems or suggestions regarding the post please comment.

301 Redirect Non-WWW to WWW URLs

Paste the below codeat the top of your htaccess file.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourwebsite\.com [NC]
RewriteRule ^(.*)$ http://www.yourwebsite.com/$1 [R=301,L]

Leave a Comment

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