
Hey, Monir here from Breakui! Today, I’m going to help you solve a common problem many website owners how to redirect non-www URLs to www URLs in WordPress. If you’re running a website and want everything to go to the www version of your domain (because, let’s be honest, it just looks cooler and sometimes helps with SEO), I’ve got you covered!
Let me explain the process in a simple way, so anyone can do it. We’ll be doing this by adding some code to two important files: the .htaccess file and the wp-config.php file.
Before we get into the technical stuff, let me explain why you’d want to do this.
.htaccess FileYour .htaccess file controls many important settings in your WordPress site, including URL redirections. This file is usually located in the root folder of your WordPress installation.
Here’s the code you need to add after RewriteEngine On:
RewriteCond %{HTTP_HOST} ^yoursite\.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301]This code basically says, “Hey, if someone tries to visit the non-www version of my site, redirect them to the www version!”
Where to add this?
.htaccess file.RewriteEngine On.wp-config.php FileNow, we need to make sure WordPress also knows we want to use the www version for everything. For that, we’ll edit the wp-config.php file, which is also in the root folder of your WordPress installation.
Here’s what you need to add:
define('WP_HOME','https://www.yoursite.com');
define('WP_SITEURL','https://www.yoursite.com');What does this do?
How to do it:
wp-config.php file.

After adding these codes, go to your browser and try typing your non-www domain, like http://yoursite.com. If everything is set up properly, it should automatically take you to https://www.yoursite.com. If not, double-check your .htaccess and wp-config.php files for any typos.
1. Why should I redirect non-www to www in WordPress?
Redirecting helps create consistency for your users and search engines. It ensures that all traffic is directed to one version of your site, improving your SEO and avoiding duplicate content issues. Plus, it just makes your site look more professional!
2. Will this affect my SEO?
Yes, in a positive way! When search engines see all your traffic going to the www version, they rank your site better because you’re not splitting traffic between two URLs. This improves your overall SEO strategy.
3. Can I redirect using a plugin instead of editing files?
Yes, you can use plugins like Redirection or All-in-One SEO, but manually editing the .htaccess and wp-config.php files gives you more control and reduces dependency on plugins.
4. Is it safe to modify the .htaccess and wp-config.php files?
Yes, but make sure you create a backup before making any changes. A small mistake in these files could cause issues, but if you follow the steps carefully, you’ll be fine.
5. Can this method be used for any type of website, or just WordPress?
This guide is specifically for WordPress, but the .htaccess method works for any website that runs on Apache servers.
By the way, if you’re aiming to take your site to the next level with professional help, you might want to check out Web Design in Orlando. They offer great insights and services that can really boost your website’s performance, design & development!
That’s it! You’ve successfully redirected your non-www URLs to www in WordPress. By doing this, you’ve improved your site’s branding and SEO, and you’re giving your visitors a more consistent experience.
Hope this guide helps you set up your website properly. And if you’re still confused, feel free to reach out for help. We’re always happy to help each other out, right?
Good luck with your website journey, and stay tuned for more tips!
Copyright © 2026. BreakUi. All rights reserved.
Made by Breakdance page builder.