Before we solve 301 redirect problem first we have to know what is Redirects . Redirects are commands that we give to the search engines when we need to, well, redirect them elsewhere. Search engines are robots, and although they are really smart, their algorithms don’t always get the semantics of a website.
301 redirects(a.k.a. permanent redirects)
301 redirects(a.k.a. permanent redirects) are used to permanently move a site to a new location. Search engines do not apply penalties to 301 redirects the way they apply them to many other types of redirects.
Some times when you generate SEO reports you see 301 redirect problem. The most common one is you website example.com is not redirecting to www.example.com. Redirecting requests from a non-preferred domain is important because search engines consider URLs with and without “www” as two different websites.
Note: if you solve this problem then you can get 15% increase in search traffic
How to solve 301 Redirects
First create .htaccess file on root folder (public_html) with following codes
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^codentricks.com [nc]
rewriterule ^(.*)$ https://www.codentricks.com/$1 [r=301,nc]
Replace codentricks.com with your domain name.
This tutorial is tested on apache.