Redirect a WordPress site from non-WWW to WWW

To redirect your WordPress site’s domain from non-www to www or vice versa then follow the steps to  show you how to do it. Redirecting one to the other is useful for SEO

Larger websites that contain subdomains must use www. As a result, it will not handle the visitors browsers cookies correctly.

With www, browsers store cookies for the website as a whole, including all subdomains.

Without www, browsers must store a separate cookie for every subdomain request. As you can imagine, the process is highly inefficient and slows down loading times on the website as a result.

Redirect-HTTP-to-HTTP

For those who would like to add www to your WordPress website, there are a couple of ways to do this, regardless of whether it’s for a site with multiple subdomains.

Just be careful. One wrong move and you could end up with the white screen of death. It may be looking  simple to execute the change from non-www to www, but it will have far-reaching effects on your website and It will change the followings:

  • The web address for visitors on the frontend.
  • The login URL for you and other WordPress users’ block or terminate access.
  • The functioning of internal and external links pointing to the website.

1. Add WWW in the WordPress Admin

From the WordPress dashboard, visit General Settings. On this screen, you’ll need to update these two fields:

Add www. after “https://” and hit Save Changes.

WordPress should immediately log you out at this time. If it doesn’t, you’ll do this on your own.

2. Add WWW with the wp-config.php File

If you want to hard-code the domain name change into the website, use the wp-config.php file to do so.

Visit your control panel and open your file manager or FTP manager. Then, locate the wp-config.php file and add the following lines of code:

define( ‘WP_HOME’, ‘https://www.your-businesses-etc.com’ );
define( ‘WP_SITEURL’, ‘https://www.your-businesses-etc’ );

Just remember to replace your-businesses-etc.com with your domain name. When you’re done, save your changes.

you might need to perform a search and replace on the database to change all other references, depending on your plugins and theme of the old non-WWW URL to the new one. The easiest way to do this is through WP-CLI.

Go to your domain manager and configure a 301 redirect to push traffic from the non-www:

https://your-businesses-etc.localhost

To the www URL:

https://www.your-businesses-etc.localhost

This enables you to capture all web traffic looking for your.

You should search each one to make sure it’s well reviewed, widely used, and actively updated When choosing a plugin for this purpose. We recommend some plugins that can help with each redirect case.

1. Redirection by john godley
Safe Redirect Manager

01 Redirects – Easy Redirect Manager

Add Your Heading Text Here

Leave a Reply

Your email address will not be published. Required fields are marked *

X