A single canonical domain is SEO rule #1. Pick one (usually non-www) and 301-redirect the other. Setup: nginx — separate server block for www with return 301; Apache — RewriteRule in .htaccess; Cloudflare — Page Rule. You need a cert for both (usually wildcard or SAN).
Below: step-by-step, working examples, common pitfalls, FAQ.
Free online tool — redirect checker: instant results, no signup.
example.com and www.example.comcertbot -d example.com -d www.example.comcurl -I https://www.example.com → HTTP/1.1 301 Moved Permanently, Location: https://example.com| Scenario | Config / Record |
|---|---|
| nginx minimal | server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate /path/fullchain.pem;
return 301 https://example.com$request_uri;
} |
| Apache .htaccess | RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] |
| Cloudflare Page Rule | URL: www.example.com/* → Forwarding URL → 301 → https://example.com/$1 |
| Reverse: non-www → www | server_name example.com; return 301 https://www.example.com$request_uri; |
| curl test | curl -ILk https://www.example.com 2>&1 | grep -iE "HTTP|Location" |
Server not found on attemptTo redirect www to non-www, use a 301 redirect in your web server configuration or .htaccess file. For Apache, add RewriteEngine On and RewriteCond %{HTTP_HOST} ^www\.(.*)$ followed by RewriteRule ^(.*)$ http://%1/$1 [R=301,L]. For Nginx, include server { listen 80; server_name www.example.com; return 301 http://example.com$request_uri; } in your server block.
A redirect from www to non-www is crucial for maintaining a consistent domain presence and ensuring optimal SEO performance. Search engines treat www and non-www as separate entities, which can lead to duplicate content issues and diluted link equity. By implementing a 301 redirect, you inform search engines that the non-www version should be the authoritative version of your site. This practice not only consolidates traffic but also enhances your site's credibility.
Moreover, user experience plays a significant role here. Users may type either version of your domain into their browsers. By redirecting one version to another, you ensure that visitors always land on the correct site, thus reducing bounce rates and improving engagement metrics.
To implement this effectively, you need to understand the server environment your website is hosted on. Here, I will outline the steps for both Apache and Nginx, the two most commonly used web servers.
For Apache servers, you typically use the .htaccess file to configure redirects. This file is located in the root directory of your website. If you do not have an .htaccess file, you can create one. Ensure that your server has the mod_rewrite module enabled, as this is necessary for the redirect to work.
Here’s how to set it up:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]In this configuration:
RewriteEngine On enables the runtime rewriting engine.RewriteCond %{HTTP_HOST} ^www\.(.*)$ checks if the HTTP host starts with www.RewriteRule ^(.*)$ http://%1/$1 [R=301,L] redirects the request to the non-www version while preserving the requested URI.If you are using Nginx, the process is slightly different. Nginx configurations are typically found in the /etc/nginx/sites-available/ directory. You will need to edit the configuration file for your domain.
Here is a basic example of how to set up the redirect:
server {
listen 80;
server_name www.example.com;
return 301 http://example.com$request_uri;
}In this setup:
listen 80; specifies that the server is listening on port 80 for HTTP traffic.server_name www.example.com; defines the server block for the www version.return 301 http://example.com$request_uri; issues a permanent redirect to the non-www version while preserving the requested URI.After configuring the redirect, it is essential to test it to ensure it works correctly. You can use tools like HTTP Status Checker or simply enter the www version of your domain in a web browser to see if it redirects to the non-www version.
Additionally, you can use command-line tools such as curl to verify the redirect:
curl -I http://www.example.comThis command will return the HTTP headers, and you should see a 301 Moved Permanently status along with the new location pointing to the non-www version.
After implementing the redirect, ensure that all internal links on your site point to the non-www version. This consistency aids search engines in indexing your site correctly and helps users navigate without confusion.
In summary, redirecting from www to non-www is a crucial step in managing your website's SEO and user experience. By following the guidelines above, you can seamlessly implement this redirect and maintain a strong online presence.
Incorrect or long redirect chains slow down the site, lose PageRank and confuse search crawlers. The tool visualizes the full redirect chain with response codes and timing for each hop.
Shows each redirect step: URL → code → URL → code, through to the final destination.
Measures latency at each redirect step for precise identification of performance bottlenecks.
Distinguishes 301, 302, 303, 307, 308 — each has different behavior for SEO and browsers.
Automatically detects circular redirects and warns before the browser throws an error.
redirect chain audit
301/302 debugging
HTTPS redirect check
UTM link tracking
Redirect check history and API for automated chain auditing.
Sign up freeDoesn't matter — pick ONE canonical and use it consistently. Google and Yandex have long treated both equally.
Yes. The client first establishes TLS with www.example.com — the cert must be valid. Only then does the server return 301.
301 — permanent, allows method change POST→GET. 308 — same but preserves method. For www→non-www use 301 — universally supported.
<a href="/en/redirects">Enterno Redirects Checker</a> shows the chain and warns on loops. Or <code>curl -I -L</code> (follows redirects) — more than 10 hops = problem.
Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.