Setting up a redirect from the WWW version to the non-WWW version of your website, or the other way around, is more than a preference. It’s a technical decision that affects your site’s performance, SEO, and user experience. One practical reason to set up these redirects is to handle problems with SSL certificate recognition.
For example, a subdomain like www.staging2.yourdomain.com might not receive an SSL certificate because of how it’s configured. That leads to security warnings that scare off visitors or the people reviewing your staging website. This shows why you want both the WWW and non-WWW versions of your domain redirected properly, so you avoid those problems.
Another example is platform-specific requirements. Platforms like HubSpot, which offers a Content Management System (CMS) for digital marketing and website management, may require a specific redirect configuration before you can fully use their services.
This isn’t only about meeting technical requirements. It’s also about keeping the services your site depends on working together and functioning correctly. Redirects are a basic part of website setup, and they support the wider digital marketing strategies and tools you rely on, which makes them hard to skip on today’s connected web.
In this article, we cover the steps and considerations for setting up a redirect from the WWW to the non-WWW version of your website or the reverse. We start with the technical details of SSL certificates and configuring DNS settings, then move to changes in your web server’s configuration files. The goal is a complete guide.
You might be trying to secure your website, meet platform-specific requirements like HubSpot’s CMS, or just clean up your site’s URL structure for better SEO and user experience. Either way, this article walks you through the process so you have the information you need to make informed decisions and make the changes cleanly.
Understanding the Importance of WWW vs. Non-WWW Redirection
The consistency of your website’s URL matters. The difference between WWW and non-WWW URLs (such as www.yourdomain.com vs. yourdomain.com) might look small, but it carries real weight for SEO, user experience, and the technical health of your website. Redirecting from WWW to non-WWW or the reverse keeps your website on a single canonical URL structure, which matters for search engines and user navigation.
Technical Implications of SSL Certificates
One practical reason to set up a redirect is the issue of SSL certificates. A subdomain like www.staging2.yourdomain.com might run into trouble getting an SSL certificate, which leads to security warnings that could turn visitors away. Making sure both the WWW and non-WWW versions of your domain redirect to the secure version (https) prevents these issues and keeps things safer for your visitors.
Platform-Specific Requirements
Some platforms, such as HubSpot, require specific redirect configurations to use their CMS effectively. For instance, redirecting non-www URLs to www URLs or the reverse might be a prerequisite for connecting your website to their services, which is why it helps to know how to configure these redirects properly.
SEO and User Experience
Choosing to redirect WWW to non-WWW or the other way around isn’t only a technical decision. It’s also an SEO strategy. Search engines treat these as two separate versions of your site, which can split your website’s search equity. With a 301 redirect, you consolidate your website’s authority onto one version and strengthen your SEO. A consistent URL structure also helps user experience by preventing confusion and keeping your site easy to reach.
How to Decide Between WWW and Non-WWW
The decision to use WWW or non-WWW in your website’s URL should come from technical, aesthetic, and functional considerations. Historically, WWW signaled that a website was part of the World Wide Web, but today it’s mostly a matter of preference. Even so, weigh factors like how easy the SSL certificate is to set up, subdomain management, and platform requirements when you make your choice.
Here at Zealous Sites, we prefer no WWW for our customers who use WordPress websites. And for any customer on HubSpot, we use the WWW.
In the next sections, we’ll get into the technical process of setting up these redirects, with attention to .htaccess rules, DNS configurations, and the steps for a smooth redirection. You might be an experienced website owner refining your site’s URL structure, or new to web development. Either way, knowing how to redirect one version of the URL to another is a key skill for running a successful site.
Bonus Reading:
- Learn more about SSL certificate implications for your website and how to address them: Rank Math’s Guide on Editing .htaccess for Redirection
- For an in-depth guide on configuring DNS settings for effective redirection: Configuring DNS for website redirection
- Discover how to use .htaccess for redirecting URLs effectively: Using .htaccess for redirection
Step-by-Step Redirection Guide
Setting up a redirect from the WWW to the non-WWW version of your website, or the reverse, takes a series of steps that touch different parts of your site’s setup, including DNS configurations, server settings, and keeping the experience smooth for users. Let’s break down these steps to guide you through the redirection process.
Preparing for Redirection
- Decide on Your Preferred Domain Structure: Before you get into the technical details, decide whether you want your site to appear with WWW or without it. This decision affects both the look of your URL and how search engines index your site. Remember, consistency is key to keeping your site’s SEO integrity intact.
- Backup Your Website: Always start by backing up your website, especially the .htaccess file or Nginx server blocks if you’re working at the server level. A small mistake editing these files can make your site inaccessible, so a backup lets you restore your site to its original state if you need to.
Editing the .htaccess File for Apache Servers
- Access Your .htaccess File: Locate your .htaccess file in the root directory of your website. If you’re using a hosting control panel like cPanel, you can reach it through the File Manager. For sites hosted on servers without a control panel, you can use an FTP client to access the file.
- Implement the Redirect Rule: To redirect non-WWW to WWW or the reverse, you’ll add specific lines of code to your .htaccess file. Here’s an example for redirecting non-WWW to WWW:
apacheRewriteEngine OnRewriteCond %{HTTP_HOST} !^www.RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
And for WWW to non-WWW:
apacheRewriteEngine OnRewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
These rules tell the server to permanently redirect all requests to the version of your domain you chose, using a 301 redirect. A 301 is SEO-friendly and tells search engines and browsers to treat the redirect as permanent.
Configuring DNS Records
- Update DNS Settings: Adjust your DNS settings so that both the WWW and non-WWW versions of your domain point to your website. This usually means configuring A records for both versions or setting a CNAME record for one version to point to the other.
Redirection for Nginx Servers
For websites hosted on Nginx servers, the redirection process is a little different from Apache servers. Instead of a .htaccess file, you’ll edit the server block configuration files. Here’s how to redirect WWW to non-WWW in Nginx:
nginxserver { server_name www.example.com; return 301 $scheme://example.com$request_uri;}
And to redirect non-WWW to WWW:
nginxserver { server_name example.com; return 301 $scheme://www.example.com$request_uri;}
Make sure to replace `example.com` with your actual domain name. These configurations tell Nginx to redirect all traffic from one version of the domain to the other while keeping the full request URI.
Testing and Verification
After you set up your redirects, test them carefully to confirm they work as expected. Use tools like HTTP status code checkers to verify that your redirects return a 301 status code, which signals a permanent redirect. Browsing your website in incognito mode also helps you see the redirects in action without cached versions of your site getting in the way.
By following these steps carefully, you can redirect WWW to non-WWW or the reverse, consolidate your domain’s SEO strength, and improve user experience. Always remember to watch your site’s performance after you make the change, so you catch any unexpected issues early.
Troubleshooting Common Redirection Issues
Even with careful setup, redirection from WWW to non-WWW (or the reverse) can sometimes cause issues that affect your website’s accessibility and performance. Here are some common problems and how to address them, drawing on guidance from resources like Rank Math.
Infinite Redirect Loops
One of the most frequent issues is the infinite redirect loop, where the website keeps redirecting between WWW and non-WWW versions and never settles on one. This can come from conflicting redirection rules in your .htaccess file or server configuration. To fix it, make sure you have a single, clear rule for redirection and no conflicting rules that bounce the server between states. Double-check the syntax and logic of your .htaccess rules so they correctly set up your preferred domain structure.
SSL Certificate Errors
If your website is set to redirect to the HTTPS version but the SSL certificate isn’t configured correctly for both WWW and non-WWW versions, visitors might see security warnings. This usually happens when the SSL certificate doesn’t cover both versions of the domain. To fix it, you might need to adjust your SSL certificate configuration so it covers both versions of your domain, or get a certificate that covers both automatically.
DNS Configuration Mistakes
Improper DNS settings can also cause redirection errors. If the DNS records for your WWW and non-WWW versions don’t point to your server correctly, or if there’s a delay in DNS propagation, your redirects might not work as intended. Verify that your DNS records are set up correctly for both versions of your domain and give them some time to propagate across the internet.
Plugin or Theme Conflicts
For WordPress users, plugin or theme conflicts can sometimes interfere with redirects. If you’re using a plugin to manage redirects or a security plugin that includes redirection features, make sure those settings are configured correctly and don’t conflict with your manual .htaccess rules. Deactivating plugins one by one and testing your site’s behavior can help you find out whether a specific plugin is causing the problem.
By checking these areas methodically, you can diagnose and resolve most common redirection issues and keep your site reliably on your preferred WWW or non-WWW domain structure. For more detailed troubleshooting advice and solutions, the Rank Math guide is a great resource: How to Redirect WWW URLs to Non-WWW.
Advanced Considerations and Conclusion
Redirecting in WordPress Using Plugins
Redirecting URLs from WWW to non-WWW or the reverse gets much simpler with plugins, especially in the WordPress ecosystem. Plugins like Redirection or Simple 301 Redirects give you a clear interface for managing redirects without editing .htaccess files directly. These tools let website owners set up and manage redirects efficiently, with features like conditional redirects, logging, and monitoring of 404 errors. With plugins like these, even people without technical expertise can handle complex redirection scenarios and keep their WordPress website on the preferred domain structure while reducing the chance of errors.
Updating URLs in Content and Database
After you set up a site-wide redirect, you’ll want to update internal links in your content and database to match the new preferred domain structure. This step prevents unnecessary redirects, which can slow down your site and hurt user experience and SEO. WordPress plugins like Better Search Replace can automate this, letting you search for the old domain (WWW or non-WWW) and replace it with the new one across all posts, pages, and options in your database. This keeps your site consistent, improves performance, and protects your SEO strength by removing internal redirect chains.
Monitoring and Maintaining Redirection
Once redirection is in place, ongoing monitoring keeps everything working as intended. Tools like Google Analytics and Google Search Console help you track your site’s performance and spot potential issues with redirects, such as higher bounce rates or crawl errors. Watching these metrics lets you catch and fix problems quickly, so your redirection setup keeps supporting your site’s SEO and user experience goals.
In Conclusion
When it comes to your website, the choice between a WWW or non-WWW URL structure is more than a trivial one. It’s a strategic move with real implications for your online presence. This guide has covered the technical ground of DNS configurations, .htaccess and server block adjustments, and the important role of SSL certificates, with the aim of giving you the knowledge to make informed decisions about your website’s domain structure.
Setting up redirects, whether from WWW to non-WWW or the reverse, comes down to improving your site’s SEO performance, strengthening security, and providing a smooth user experience. By using plugins for WordPress or working through manual redirect configurations, you’ve seen how these actions contribute to a strong online presence and keep your website consistent, accessible, and optimized for search engines and visitors alike.
As we wrap up, remember that the web keeps changing, and staying on top of your website’s redirection setup matters. Regular monitoring and updates keep your chosen domain structure serving your site’s goals as SEO practices, technology, and user expectations shift.
Getting your website’s domain presence right is an ongoing job, but with the insights and tools in this guide, you’re well-equipped to handle it with confidence. Here’s to your site’s move from WWW to non-WWW (or the reverse) starting a cleaner, more search-engine-friendly, and user-focused experience.
Frequently Asked Questions
Why is my site redirecting to www?
Your site might automatically redirect to the WWW version because of your web server’s configuration or DNS settings. This can happen if your website is set up to favor the WWW version as the canonical URL, either through specific rules in your server’s .htaccess file (for Apache servers) or server block configurations (for Nginx servers). Web hosting platforms often have settings that drive this behavior, aiming to keep things consistent with the chosen domain structure.
If your website is WordPress, check your .htaccess file to see if there’s a redirect set up there. If you’ve recently changed the domain structure an old .htaccess file might be causing you some troubles.
Is it better to use www or non-www?
Choosing between WWW and non-WWW is largely a matter of personal preference, but there are technical considerations to keep in mind. Using WWW can help with managing cookies, CDN setups, and distinguishing between different types of traffic, since it technically allows for more flexibility with DNS and can aid in load balancing and website performance. On the other hand, non-WWW domains are shorter, cleaner, and have become more popular for branding purposes.
Both versions are equally effective from an SEO standpoint, as long as you consistently use one version and correctly set up redirects from one to the other.
How do I stop my website from redirecting?
To stop your website from redirecting from non-WWW to WWW (or the reverse), you’ll need to adjust your website’s server configuration. This means editing the .htaccess file on Apache servers or the server block configuration files on Nginx servers to remove or change the redirection rules. If you’re using a content management system like WordPress, you might also need to check whether any plugins or settings within your CMS are enforcing these redirects.
Additionally, make sure your DNS settings don’t automatically enforce a particular version of your domain by default.