EID Offer Reloaded 50% Off on All Themesgrove Products!

Coupon Code: EID50

BLACK FRIDAY
60% OFF
Coupon Code: BF60

How to Redirect WWW to Non WWW and Vice Versa in WordPress

Many people often ask the question regarding redirect www to non www and vice versa of their website URL. If you go through WordPress forums, you can notice many people asking questions related to removing www or adding www in their websites’ URL. Moreover, many of you are scared about whether it will affect your website ranking or not. 

Let me clear the confusion for you. It doesn’t matter whether you include www or not. Eventually, the search engine takes note of the consistency and quality of your website. So, you should pick only one URL format and keep updating your website regularly with latest technology.

At first, decide which URL you prefer. Then, redirect that URL and don’t change the format unless you face any emergency. 

In this tutorial, you’re going to learn to accomplish such a task using the .htaccess file and cPanel

Redirect WWW to Non WWW or Reverse: Which One to Choose?

The truth is, whichever you go for doesn’t really matter, it is not that important, like for example http to https. Generally, most webmasters decide between non-www to www  or to redirect www to nonwww based on aesthetics.

Non-www URLs are shorter and oftentimes cooler to look at, compared to their www counterpart. Other than that, there’s nothing else.

None has an SEO advantage over the other, and none has a faster load time than the other. What matters is specifying which format you prefer, and then redirect visitors to your chosen URL format.

How to Redirect to WWW or Non-WWW?

Redirecting WordPress website URL isn’t a that level of tough job. You can do it yourself in minutes. WordPress website let you redirect www to non-www and vice versa. I am going to demonstrate you both procedures. 

There are popular two ways to make this work done. First one is through .htaccess file and another is using your website cPanel. Let’s do it through both ways.

Using .htaccess File

As you know .htaccess is one of the most vital files of a WordPress website, it mainly handles the redirects. So, access the .htaccess file with care.

Step 01

As always, you need to log in to your cPanel account and open the file manager from Files’ section, it consists of all the core files and folders of your WordPress site.

How to Redirect WWW to Non WWW and Vice Versa in WordPress 1

Step 02

Find out public_html from the left vertical navigation menu and click that file. 

How to Redirect WWW to Non WWW and Vice Versa in WordPress 2

Step 03

Search for the .htaccess file. As you can see, .htaccess has a dot prefix, which reflects its nature to be a hidden file. 

If it happens you couldn’t find the .htaccess file, chances are that it is hidden. To display the hidden file, click on the Settings button at the top right corner of the screen. A dialog box will pop open as soon as you click the button. In the box, check Show hidden dotfiles and click Save.

How to Redirect WWW to Non WWW and Vice Versa in WordPress 3

Once you find the file, right-click to edit.

How to Redirect WWW to Non WWW and Vice Versa in WordPress 4

Step 04

A popup appears to authenticate your permission to edit. Click on Edit button, and a new tab opens up on the browser.

How to Redirect WWW to Non WWW and Vice Versa in WordPress 5
Step 05

Now is the time to add the code.

To redirect www to non-www, copy and paste the following lines of code at the bottom in the .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.your-domain.com [NC]
RewriteRule ^(.*)$ http://your-domain.com/$1 [L,R=301]
</IfModule>

Ensure you replace your-domain.com with the actual domain of your website. Once you are done, click the save button.

If you would like to do the reverse, that is redirect non-www to www, use the following code instead. 

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^your-domain.com [NC]
RewriteRule ^(.*)$ http://www.your-domain.com/$1 [L,R=301]
</IfModule>

Ensure you replace yourdomain.com with the actual domain of your website. Once you are done, click the save button.

How to Redirect WWW to Non WWW and Vice Versa in WordPress 6

Using cPanel 

This is easy to do with cPanel. Login to your cPanel to get started.

Go to Domains > Redirects on the cPanel main page.

Now depending on whether you prefer the URLs with the www part or without the www part, the instructions will differ a bit.

Redirect to non-www

How to Redirect WWW to Non WWW and Vice Versa in WordPress 7
  1. Set the type to permanent to give a 301 HTTP status code.
  2. Select the main domain from the drop down menu.
  3. Leave the path empty, we want to redirect the entire domain.
  4. Set the URL to redirect to without the “www” part in it.
  5. Choose “Only redirect with www“
  6. Leave the “Wild Card Redirect” unchecked.

Redirect to www

How to Redirect WWW to Non WWW and Vice Versa in WordPress 8
  1. Set the type to permanent which will give an HTTP 301 status code.
  2. Choose your main domain in this drop down.
  3. Leave the path empty, you want to redirect the entire domain.
  4. Specify the URL to redirect to with the “www” part in it.
  5. Choose “Do Not Redirect www“.
  6. Leave the “Wild Card Redirect” unchecked.

Final Words

So, this is the procedure to redirect www to non-www and vice versa. If you face any complication while you will change this, let us know through the comment box. Our team is always ready to serve you. 

You can check our another “Quick Fix” tutorial from these links.

How to Fix Regular PHP Issues for WordPress-WordPress QuickFix

How to Remove Add to Cart Button WooCommerce-WooCommerce QuickFix

Similar Posts

Leave a Replay

Shams Sumon
Shams Sumon
Love to write and currently working with Themesgrove.

WP Onepager

The most beginner friendly page builder for WordPress.

WidgetKit For Elementor

Visually stunning and simple to use premium addons for Elementor Page Builder

Sign up for our Newsletter

Your privacy is important to us. We never share or sell any data to anyone.

Christmas Login

login

Don’t have an account? signup