What is a 301 Permanent Redirect?
3012 Permanent Redirect is a response code by the browser which tell the browser that the requested page is moved and tell the new location to the browser. The browser reaction for such response is that automatically redirecting the user to the new location. Search engines will direct all the authority of the 301 redirects to the new location.
When to Use a 301 Permanent Redirect?
You need to use 301 permanent redirects if you have any of the following:-
- Transferred your website to different domain/location
- Moved or renamed a page and do not want to lose traffic coming to old location
How to make 301 Permanent Redirect?
There are many ways to make 301 permanent redirects. We will mention the most common ones.
By creating .htaccess file in the root directory of your website and entering the following text you will instruct the HTTP server to redirect users visiting oldpage.html to newpage.html
RewriteRule ^oldpage.html$ newpage.html$1 [L,R=301,NC]
Using Server side language(i.e. PHP)
By writing the following code in the page oldpage.php you will instruct HTTP server to redirect visitors of oldpage.php to newpage.php
header("HTTP/1.1 301 Moved Permanently");
header('Location: /newpage.php ');
The rel=”canonical” Attribute
The rel=”canonical” attribute is not a redirect, rather it is an indication solely for search engines to tell them which page to index. Say if you have almost identical contents on two different locations using rel=”canonical” attribute will tell search engines which page of the two you want appearing in search engines. However according to google, the rel=”canonical” will be used as a direction or hint to choose the best page to index which means under some conditions google may choose to ignore rel=”canonical” attribute and index the other page which you do not want to index.
When to use Canonical?
- When 301 can not be implemented (.htaccess is disabled or there is no server side language)
- When you have duplicate contents but you want to keep both pages live
When to avoid using Canonical?
- There is no much duplicated contents between the two pages
- With paginated pages
- With related but different pages