In this tutorial, we will demonstrate how to redirect www to non www URLs. In particular, we will be looking at how to achieve this with the help of a 301 redirect.
What is the www in a URL?
The www in the URL of a website stands for World Wide Web and the “www.” was used as a subdomain in the early days of the internet to distinguish the website on a domain from other properties on that domain.
For instance, www.example.com would be used to host the main website and the blog could be hosted on blog.example.com.
Do I need the www in the URL of my website?
It is your choice. You can retain the “www.” part in the domain of your main website or you may choose to remove it.
As a web design agency, we at Caweem, we recommend removing the “www.” part from your URL because it is unnecessary and results in a shorter URL which is easier for everyone to remember.
If you would like to host multiple websites or applications on the same domain, you may host these applications or websites on different subdomains without having to host the main website on the www subdomain.
For instance, you can host your main website on example.com, and host your web app on app.example.com.
Why should I redirect www to non www URL?
If you have the exact same website hosted on both the main domain and on the www subdomain, search engines will crawl both webistes, i.e. example.com and www.example.com as two distinct websites, which could result in duplicate content issues.
To avoid such issues, you will have to redirect your URL from www to non www.
How to redirect a URL with www to non www URL?
In order to redirect a www to a non www URL, you will have to access the files on your website server via SSH or FTP and find the .htaccess file.
Once you have found the .htaccess file, download it to your local machine and add the following code to the .htaccess file:
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
After adding the above code, save the .htaccess file and upload it back to your server.
Below is an example of what you should be doing:
The URL of your website with www will now be redirected to the non www URL.
Updated:
0 Comments