Mar 02, 2026
Merkys M.
5min Read
As a website owner, you might have wondered whether using a www or non-www website domain is simply a matter of user preference.
Even though a non-www domain may be simpler and easier for your audience to remember, it has some disadvantages compared to a www domain.
A www domain helps avoid both the possibility of split page ranking or split inbound links and any duplicate content when search engines index the site. Thus, it improves your site’s search engine optimization (SEO).
If you use a non-www URL, redirecting it to www may seem intimidating, but it’s not a complicated process. Keep reading, as this article will show you three different methods to redirect non-www to www URLs.

Sticking with a non-www domain has some drawbacks, including the lack of overload protection and control over cookies.
Traffic from non-www domains can’t be redirected to another server because they don’t have a CNAME record. Due to that, if your server experiences an overload, you won’t be able to redirect traffic to a healthy server.
Thus, visitors may have a hard time accessing your website, negatively affecting its performance and SEO.
In addition to that, search engines consider https://www.yourdomain.com and http://yourdomain.com different websites. Therefore, they are ranked separately and require distinct SEO strategies.
Also, with a non-www domain, you can’t use a cookie-free subdomain unless you create a separate domain to deliver static content.
On the other hand, a www URL allows you to restrict cookies to the root domain or a specific subdomain, reducing the number of HTTP requests and improving the performance of the website.
There are several ways to redirect non-www URLs to www – via your hosting account’s control panel, a content delivery network (CDN), or web server software.
To avoid losing your ranking power, we recommend performing a permanent 301 redirect instead of a temporary one.
Warning! Before proceeding to the tutorial, make sure you have a backup of your website files. This way, you can restore the site to a previous version if an error occurs during the process.
The easiest way of redirecting a non-www URL to www is to place a rule in the .htaccess file. You can do so via FTP, SSH, or your hosting account’s control panel.
hPanel users can easily access and edit the .htaccess file. Here are the steps to do it:


RewriteEngine On and insert the following code after it:RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
This .htaccess rule will now redirect all visitors from the non-www to the www version of your website.
cPanel users can redirect non-www URLs to www via the Redirect settings or editing the .htaccess file. If you are a beginner, we recommend following the first method:


If the above method doesn’t work, you can set the redirect manually by editing the .htaccess file:



RewriteEngine On, insert the following lines of code:RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
Important! Don’t forget to replace yourdomain.com with your actual domain name.
If you’re planning on setting up a CDN like Cloudflare to improve the speed and performance of the site, you will also be able to use it to redirect the non-www to the www domain.
You may want to check the following tutorials before proceeding:
Cloudflare setup process for WordPress sites
Cloudflare setup tutorial for general websites
Once you’ve created an account, log in, and set up a page rule on your Cloudflare:


Wait for the redirect to go live.
If you use virtual server hosting and NGINX, follow the tutorial below to redirect non-www URLs to www:
[server]$ sudo ls - la[server]$ sudo nano nginx.confserver {server_name yourdomain.com;return 301 $scheme://www.yourdomain.com$request_uri;}sudo systemctl restart NginxIn addition to redirecting non-www to www URLs, you can also run other redirects through NGINX, such as HTTP to HTTPS and other page redirects.
Hostinger users can manage their VPS from the new browser-based terminal, eliminating the need for additional software.
If you’re a VPS and Apache user, you’ll also need to edit the .htaccess file. Just like the previous tutorial, it can be done via an SSH terminal.
Important! Before continuing with the steps below, make sure you have root access with sudo privileges and a text editor like Nano.
By default, Apache doesn’t allow the use of .htaccess file, so the steps will be a little different:
$ sudo a2enmod rewrite$ sudo systemctl restart apache2$ sudo vi /etc/apache2/sites-available/000-default.conf<VirtualHost> line:<Directory /var/www/html>Options Indexes FollowSymLinks MultiViewsAllowOverride AllRequire all granted</Directory>$ sudo vi /var/www/html/.htaccessRewriteEngine onRewriteCond %{HTTP_HOST} ^yourdomain.com [NC]RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]All site visitors using the non-www URL should now be redirected to the www version.
People tend to leave the www out when typing a website’s address. It might not cause significant issues since visitors will reach the same page, but it’s best to redirect site visitors to its www version.
This is because your site’s performance and SEO might be affected if you keep using non-www domains.
Though it may sound complicated, the redirect process will only take a minute or two. In this article, you’ve learned how to redirect non-www URLs to www in several ways:
Now, whenever someone accesses your site using http://yourdomain.com, they will be redirected to http://www.yourdomain.com.
We hope this article was helpful. Let us know in the comments below if you have any questions.
Check out our tutorial featuring The Best Tools For Website Optimization, ensuring a smoother and more engaging user experience.