How To
How To 301 Redirect www to non www URLs Using HTACCESS
The internet is full of information and all of them are properly categorized or distinguished by URLs (Uniform Resource Locators). If you purchase a domain, you will naturally get two URLs for it i.e., www.example.com and example.com. Most of the browsers consider www and non-www URLs as one and the same. But in cases of search engines, it is a different story.
Almost all search engines consider www and non-www URLs as different pages of a website. So, if your website is not redirected from www to non-www or non-www to www version, search engines will consider that you have two pages of same content. This will result in duplicate content issue and because of this your website rankings will get affected.
So, to resolve this issue you will need to 301 redirect (permanent redirection) www addresses to non-www or non-www addresses of your website to www. Although there are different ways to do this task, the simple way is by using the .htaccess file located in your server (Linux servers). Let’s find out the tutorial for redirecting www to non-www URLs and non-www to www URLs using .htaccess.
Tutorial To 301 Redirect www to non www URLs Using .htaccess:
1) To get started, log into the cPanel of your website and open the File manager (make sure that you have enabled “Show Hidden Files” option or else the .htaccess file won’t show up under “File Manager”).
2) Next, add the following code in the .htaccess file:
Once done, save the file.
That’s it. Now, you have successfully redirected www addresses of your website to non-www.
Tutorial To 301 Redirect non www to www URLs Using .htaccess:
To 301 redirect non-www URLs of your website to www addresses, enter the following code in the .htaccess file in your server:
(Note: Replace example.com with your domain name).
Tutorial To Redirect example.com/index.php to example.com using .htaccess:
Since search engines consider all URLs as separate pages, you will need to redirect your index.php page (if you have created your website using .php then this will be your homepage) to the primary domain. To do so, enter the following code in .htaccess:
(Note: Replace example.com with your domain name).
Make sure that you copy and paste the codes given here properly in your .htaccess file or else, your website will not work properly. Also, if you have any queries regarding 301 redirection of your website using .htaccess, drop a comment below.
Post a Comment
0 Comments