How to Redirect Non-www to WWW in WordPress

With the advancement of SEO, most of the SEO specialists see the importance of having both www and non www version of the domain. In fact, most of the web users feel more comfortable in typing the non www URL in their browser as they feel it’s more easy to remember. So they try to type the nonwww URL in the address bar and if they miss out the “www” they end up on the wrong site. This can be very frustrating for the visitor. So here’s a solution to redirect non www to www without any WordPress plugin.

Force Non-www to WWW version in WordPress

Here are 4 effective ways on how you can change your non-www WordPress URL to a www version.

Change WordPress site URLs settings

Change Non Www To Www Via Wordpress Admin
  1. Login to your WordPress backend
  2. Go to general settings
  3. Look for WordPress address and Site address (URL)
  4. Add www and hit save

Add redirection rule via .htaccess File

Change Non Www To Www Via Wordpress Admin
  1. Go to your WordPress hosting file manager
  2. Look for the .htaccess file on the root folder
  3. Click edit via file editor
  4. Add the script below on top of the .htaccess
  5. Hit save
  6. You can also use Rank Math’s edit .htaccess option to locate this file
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ [NC] 
RewriteRule ^(.*)$$1 [L,R=301,NC]

Change to WWW version with phpMyAdmin Tool

Change Non Www To Www Via Wordpress Admin
  1. Login to your PhpMyAdmin account
  2. Click the database of your WordPress site
  3. Look for “wp_options” table
  4. Look for siteurl and home
  5. Edit values and add www 

Edit wp-config.php to change to WWW version

Change To Www Via Wpconfig File
  1. Go to your WordPress hosting file manager
  2. Look for the wp-config.php file on the root folder
  3. Click edit via file editor and look for this line “/* That’s all, stop editing! Happy publishing. */”
  4. Add the code below before that line and hit save

Non-www and WWW Versions  

When navigating through the web, you may have noticed that some websites have a URL that begins with “www” while others do not. This is because there are two versions of websites: the non-www version and the WWW version. Although they may seem identical to the everyday user, there is actually a difference between the two. 

First and foremost, it is important to note that the WWW version is simply a subdomain of the non-www domain version. The “www” stands for “World Wide Web,” which was the original domain used before the internet became more widespread. Nowadays, most websites simply use the non-www version as the default, but many still include the WWW version for legacy or aesthetic reasons. 

One of the main reasons why the distinction between the two versions of a website matters is for search engine optimization (SEO). When search engines crawl a website, they can perceive the non-www and WWW versions as two separate websites if they are not properly redirected. This can lead to duplicated content and lower rankings on search engine results pages. 

To ensure that your website is properly optimized for search engines, it is recommended to choose one version (either non-www or WWW) and redirect the other version to it. This can be done through your web hosting provider or by editing your website’s .htaccess file. 

Additionally, the distinction between the two versions can also affect website security. If your website has a SSL/TLS certificate (which provides a secure connection between your website and its visitors), it is important to make sure that the certificate covers both the non-www and the WWW versions of your website. Failure to do so can result in security warnings for visitors who try to access your WordPress website through the version that is not covered by the certificate. 

Problem with WWW and Non-www versions

The problem with having both WWW and non-WWW versions of your website is that it can lead to duplicate content issues, which can negatively affect your search engine rankings. When search engines crawl your website, they may see the same content on both versions and be unsure of which one is the original source. Additionally, incoming links may be split between the two versions, diluting the overall link equity of your website. 

To avoid this issue, it’s recommended to pick one version (typically the WWW version) and set up a 301 redirect to redirect all traffic to that version. This not only eliminates duplicate content issues but also consolidates the link equity to one version, giving your website a better chance of ranking higher in search engine results. It’s a simple fix that can have a big impact on your website’s SEO performance.

In conclusion, while the difference between the non-www and WWW versions of a website may seem minor, it can have a significant impact on SEO and website security. By properly redirecting one version to the other and ensuring that your SSL/TLS certificate covers both versions, you can ensure that your website is optimized for search engines and provides a secure browsing experience for your visitors.

Scroll to Top