cPanel

  • Log in to your cPanel account.
  • Navigate to the “Domains” section and click on “Redirects”.

  • Choose the domain you want to redirect from the drop-down menu.
  • Select “Permanent (301)” as the type of redirect.
  • Enter the non-www URL (e.g., example.com) as the source URL.
  • Enter the www URL (e.g., www.example.com) as the destination URL.
  • Click on “Add” or “Add Redirect”.

How to Redirect Non-www to www URLs ?

Redirecting non-www to www URLs entails ensuring that when people access your website via a URL without the “www” prefix (e.g., `example.com`), they are automatically routed to the version with the “www” prefix (`www.example.com`). This redirection is often used to maintain a consistent URL structure. It can be accomplished via server-side configuration (an Apache.`htaccess`file or Nginx configuration) or DNS settings provided by your domain registrar or DNS provider.

Similar Reads

Why Redirect Non-www URLs to www?

Consistency: It guarantees a constant URL structure for your website. Visitors to your site will always see the same URL version, whether they enter “example.com” or “www.example.com”. This uniformity can improve branding and user experience. Canonicalization: You can create a canonical version of your domain by redirecting non-www URLs to www. Search engines such as Google prefer a single canonical version of a website to prevent indexing duplicate content. To consolidate, redirect non-www to www or vice versa. Analytics and Tracking: Redirecting all traffic to a single version of your site makes tracking and analytics easier. You may get precise statistics on your website’s performance without having to reconcile data from different versions of the same page. Security: It can help to avoid cookie-related security issues. Cookies created on the non-www version of your domain may be inaccessible from the www version, and vice versa. By redirecting all visitors to a single version, you can ensure that cookies are uniformly managed and accessible across your site. Compatibility: Some services, scripts, and third-party tools may expect or need URLs to include the www prefix. Redirecting non-www URLs to www enables interoperability with such services while also avoiding potential integration difficulties....

hPanel

Log in to your hosting account’s hPanel Navigate to the “Domains” or “Domain Management” section....

cPanel

Log in to your cPanel account. Navigate to the “Domains” section and click on “Redirects”....

Cloudflare

Log in to your Cloudflare account....

NGINX

Access your server’s Nginx configuration file (commonly located at `/etc/nginx/nginx.conf` or `/etc/nginx/sites-available/default`). Open the configuration file in a text editor. Add the following server block to redirect non-www URLs to www URLs:...

Apache

Access your server’s file system and locate the .htaccess file in the root directory of your website. Open the `.htaccess` file in a text editor. Add the following code to redirect non-www URLs to www URLs:...

Conclusion

In conclusion, redirecting non-www URLs to www URLs is a best practice that enhances website usability, SEO, analytics accuracy, security, and compatibility, ultimately leading to a better overall web presence....