When setting up a WordPress website, one of the important technical SEO steps is choosing whether your site should load with www (e.g., www.example.com) or without it (example.com). After choosing your preferred version, you must set up a proper redirect so your visitors, search engines, and external links all point to the same URL.
This article explains how to redirect www → non-www on a WordPress site, step by step.
Before creating redirects, decide which version you want:
This guide focuses on redirecting www to non-www.
In your WordPress admin panel:
https://example.comhttps://example.comThis instructs WordPress to use your chosen domain version.
If your hosting uses Apache, you can easily set up the redirect in the .htaccess file located in the root directory of your WordPress site.
Add this code above the WordPress rules:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
This does the following:
If your site runs on NGINX, you need to add a redirect rule in your server configuration:
server {
listen 80;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
Then reload NGINX:
sudo systemctl reload nginx
To avoid conflicts, make sure your DNS records are correct:
example.com → points to your server IPwww → points to example.comThis ensures all www traffic flows through your main domain.
Some links, images, or scripts may still be using the www version.
You can fix this using one of these:
Use Better Search Replace to replace:
https://www.example.comhttps://example.comIf you have custom code or hardcoded links, update them to the non-www version.
Check that everything works:
http://www.example.comhttps://www.example.comBoth should automatically redirect to:
https://example.com
You can also use tools like:
Redirecting www to non-www on your WordPress site is an important step for:
By updating your WordPress settings, configuring .htaccess or NGINX rules, and ensuring DNS and internal links match your preferred domain, you create a clean and professional setup for your website.