I am writing on this subject solely due to the fact that there is no guide on 301 redirects from www to NON-www with actual images of the finished project. There are many high quality/high-techy articles with all variations of redirects and how to do them in general, but they all lack images of actual redirects implemented on a real site.
Implementing Methods That I Will Cover in This Tutorial!
- edit via notepad directly from your server with FileZilla
- edit via Yoast WordPress plugin – current official plugin name “WordPress SEO“
What Type Of 301 Redirect I Will Cover in This Tutorial?
- 301 redirect from www to NON-www
- 301 redirect from NON-www to www
Why You Need 301 Redirect From www to NON-www OR Vice Versa?
- to avoid duplicate content with search crawlers
- to give your site one primary URL
- to create consistency in indexing
- to boost your SEO rank
1) Avoid Duplicate Content With Search Crawlers.
Everyone knows by now that Google is not happy with duplicate content and will penalize you for it. You are asking yourself right now what do redirects have to do with duplicate content? This will bring us to the next point.
2) Give Your Site One URL so Called Primary URL
Technically www.matSatler.com is one domain and matSatler.com are different domains! Therefore search engines will crawl both of these separately and you will end up with duplicate content and low SEO ranking. You have to pick one and stick with it throughout to keep consistency and simplicity for crawlers. Perform 301 redirect for the other one. Below I will show you step-by-step how to do this with images to go along. Personally I picked “NON-www” domain as my primary domain. It is shorter and less keystroke to type. There is absolutely no precedence of choosing one over another. Each will produce equal SEO results.
3) Consistency in Indexing is Very Important
Search engine crawlers are on a time clock. They have only so much time to run through your site and index all your pages. If your site is simple, consistent, and organized it will give crawlers the opportunity to work faster and go a lot deeper to index all your pages. When crawlers love you they will want to come back much more.
4) This Simple Tip Will Boost Your SEO Significantly
There are many quality posts with in-depth studies and split testing to support this claim. I will not go in detail here, but I will say this; make search engines happy, follow their requests and polices and you will get rewarded with good ranking.
WWW to NON-www
a) edit .htAccess via notepad
You will need FTP access to your server. In the root folder (httpdocs) find “.htAccess” file and download it to your computer. If the file is not there than you can make one on your computer [open a notepad and save it as “.htaccess “ (note the period before the htaccess)]. Simply place below code in your newly created file (make sure to replace my domain matsatler.com with yours). Now save the file and upload it back to your root folder on the server.
# BEGIN WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} !^matsatler.com
RewriteRule (.*) https://matsatler.com/$1 [R=301,L]
# END WordPress
NON-wordpress site – please use:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^matsatler.com
RewriteRule (.*) https://matsatler.com/$1 [R=301,L]
If you already have .htAccess file on your server (like me)
Download it to your computer. It is best that you place it on the desktop so you can find it easily. Go to your desktop and right-click on the file and click “open”. If you get the popup “windows can’t open this file” . Advanced user should open it with their favorite html editor (Editplus, Dreamweaver or others)
Click on the second option “select a program from a list of installed programs” and click OK (see image below)
Now you should see a window similar to the one below with many available recommended programs. If your does not look like the one below – please click on the little arrow to the right of “other programs” (see image below) then find “notepad” and click OK.
When you finally open the file it will contain some code. First, you want to make a copy of this file. This way if you make any mistake you will have a backup. Navigate to top left and click on: FILE->SAVE AS and give it a name like “.htaccessORIG” then close it down and open the “.htaccess” again. If you have a WordPress site, find the line “# BEGIN WordPress” and paste below code right after it in the new line: [make sure to replace my domain matsatler.com with yours.]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^matsatler.com
RewriteRule (.*) https://matsatler.com/$1 [R=301,L]
BEFORE
AFTER
Save the file and upload it back to your server. Time to test your site for 301 redirects from www to NON-www. Got to your browser and type “http://www.YOURdomain.com” and press ENTER. When your site loads you should not see “www” in the browser “http://YOURdomain.com”
b) Yoast WordPress plugin
Login to your WordPress admin. In your dashboard navigate down to “SEO” and hover over to open sub-menu “Edit Files” click on it and it will bring-up a window similar to the image below. Find the line “# BEGIN WordPress” and paste below code right after it in the new line: [make sure to replace my domain matsatler.com with yours.]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^matsatler.com
RewriteRule (.*) https://matsatler.com/$1 [R=301,L]
Save File and test your site for 301 redirect from www to NON-www. Got to your browser and type “http://www.YOURdomain.com” and press ENTER. When your site loads you should not see “www” in the browser “http://YOURdomain.com”
NON-www to WWW
Follow all the steps above just use this code: [make sure to replace my domain matsatler.com with yours.]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^matSatler.com
RewriteRule (.*) http://www.matSatler.com/$1 [R=301,L]
Don’t forget to test your site. Got to your browser and type “http://YOURdomain.com” and press ENTER. When your site loads you should now see “www” in the browser like http://www.YOURdomain.com
Now, Your Turn
I could also create a video on this! If you guys think that would be helpful, please share your vote!
Let me know by commenting below!