HOW TO REDIRECT NON WWW TO WWW ON DIGITALOCEAN/NGNIX/UBONTU/SERVERPIL

Creating a redirect non www to www URL or www to non www could be both easy and difficult for digitalOcean/Nginx/Ubuntu/Serverpilot users.Here I am will demonstrate to you the most effortless strategy to divert them. To comprehend the aggregate procedure you should have information on URL redirection. On the off chance that you as of now have any thought on URL redirection at that point begin perusing from How to redirect non www to www URL on digitalocean.

What is URL Redirection?

Redirection is a strategy for supplanting one URL with another. Essentially, we utilize this redirection technique to drive activity specifically starting with one URL then onto the next one. We have to do this for different purposes. Suppose, you wrote a promotional content and you have back linked your content on many websites.You are accepting loads of activity to that connection however the limited time frame has lapsed. As you are not getting advantage from that substance you can without much of a stretch erase that limited time content and can divert your erased interface with other substance that you may need more movement.

You can without much of a stretch divert one sub URL to another sub URL under your space name. In any case, it is very hard to divert your non www to www or www to non www URL. You can divert any sub URL utilizing diverse modules on WordPress Site. Be that as it may, you can't divert www to non www URL or non www to www URL. You should have a bit of coding learning to do it. There are 5-6 techniques that you can change your site's area from non www to www URL or www to non www URL. I am will utilize htaccess strategy.

Before we proceed, we should see the arrangement or kinds of redirection. It will help us to select the right way.

Types of URL Redirection

I am not going to teach you about the classification of URL redirection.I am simply indicating you sorts of URL redirection that are generally utilized and SEO well disposed. Every one of the redirection is set apart by a reaction code.  
302 Redirect = Found or Temporarily Moved (HTTP Version 1.0).
307 Redirect = is known as “Temporary Redirect” (HTTP Version 1.1).
301 Redirect = Permanently moved (redirect).
301 redirect is the most used redirection code. 301 Redirection is good for website’s SEO because it tells the search engine that the Original URL is no longer existed and has been permanently redirected to the new one. You can redirect your website from non www to www URL or www  to non www version using 301 redirection method. 301 redirection method is good for changing your website from old domain to new domain also. As 301 redirection method SEO friendly, it will not hamper your website’s SEO. So, we are using this method to change URL version from non www to www or non www to www. It is a kind of canonicalization. Read more about canonicalization.
Well I guess, you have some idea on redirection method now. So let’s move to the next level and see

How to Redirect non www to www URL on DigitalOcean /Nginx /Ubuntu (Vise-Versa)

DigitalOcean is a cloud base hosting provider and there are no CPanel on a cloud server. So it’s quite difficult to find htaccess. Many web proprietors are scanning on google for DigitalOcean divert non www to www on google. If you are using WordPress then stop worrying because you already use a plugin that can change your htaccess file. Can you guess it? Okay, I am telling the answer. It’s YOAST SEO plugin.

Method of  non www to www URL redirection
There are lots of ways to change htaccess files. I am going with the easiest way to change htaccss files. Almost all the website owner uses Yoast Seo Plugin. Its very easy to change htaccess file from Yoast Seo Plugin.  To change your htaccess files from yoast seo plugin follow the steps below. Also, you can go with the method that I used on the video (only if you are on serverpilot).
1.Login to your WP dashboard.
2.Go to Tools from Yoast SEO.
yoast seo to tools
3.Click on File Editor. You will find two boxes. One for editing robots.txt and another one for htaccess file
non-www url to www url
4.  After
# BEING WordPress add the codes below
# Start: non www to www url 
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# End: non www to www url

Hopefully you have been successful to redirect your non www to www url.
Redirect your www URL to non www URL
It is also like the previous one. You just need to place these codes
# Start: www to non www URL
RewriteEngine On
RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# End: www to non www URL 

These are the best ways that I know and shared them for whom are searching for digitalocean redirect non www to www or www to non www URL. I figure you can now effortlessly change your coveted form of your sites URL.  
Caution:  While altering codes on htaccess on the off chance that you do anything incorrectly then your WordPress site might be crushed. At that point you need to expel the codes that devastated your WordPress.

Conclusion :
On the off chance that you are running a substance based site at that point don't utilize the two adaptations non www and www of your space. Since Google will discover two same substance in two diverse URL and you may get punished for content duplication.Still now, on the off chance that you have any issues at that point don't hesitate to remark beneath.
 

No comments

Powered by Blogger.