How to Redirect Non-WWW URLs to WWW?

Duplicate web content often exists without people knowing about it.

Most people see https://www.domain.com and https://domain.com as the same page, but search engines don’t—they see them as duplicate content. 

Google sees duplicate content as “appreciably similar” content in more than one URL. 

The major problem with duplicate content is that it’s difficult for search engines to decide on the version to include in the search index and rank for query results. 

This confusion could impact search engine rankings negatively.

But you could fix this by redirecting all non-www URLs to their www version, and thankfully, here’s how.

Redirecting Non-WWW URLs to WWW

You can create web redirects by adding some lines of code to your domain .htaccess file—a server configuration file that lets users make quick changes to their server settings. Use this code to redirect from non-www to www.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain.com [NC]

RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Please replace domain.com on the code with your domain name and save the changes. 

Always add your redirect rules below the RewriteEngine On line, unless you have it already at the top of the .htaccess file. 

How to Redirect Non-WWW URLs to WWW?, Redirecting Non-WWW URLs to WWW

If you do, then use the code without the RewriteEngine On line to create the URL redirect. 

RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]

RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

Now follow these steps to add the rule to your .htaccess file.

Step 1: Log into SPanel’s User Interface.

The default login URL is https://yourdomain.com/spanel/ (don’t forget to replace yourdomain.com with your actual domain).

How to Redirect Non-WWW URLs to WWW?, Step 1: Log into SPanel’s User Interface.

Step 2: Open the File Manager

Locate the FILES section on the homepage and click File manager.

How to Redirect Non-WWW URLs to WWW?, Step 1: Log into SPanel’s User Interface. 2

Navigate to your domain’s root directory in the file manager and open it.

If you’re setting up the redirect for your root domain, then the root directory should be the folder named public_html.

How to Redirect Non-WWW URLs to WWW?, Step 1: Log into SPanel’s User Interface. 3

If it’s for a subdomain or addon domain, choose the folder bearing its domain name.

Step 3: Add Your Code

Locate a file named .htaccess in the root directory, right-click the file to reveal a menu, then choose Edit to open the editor.

How to Redirect Non-WWW URLs to WWW?, Step 3: Add Your Code

Now, copy and paste your redirect rule into the editor and save. Then, type your URL without the www in your browser to confirm it’s redirecting to the www version.

Need Support?

If you need assistance creating this redirect, kindly reach out to our support for quick help, and we’ll be available to help.

Was this helpful?

What’s your goal today?

1. Find the right Managed VPS solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lighting fast

We guarantee to make your WordPress site load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.

Photo

Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2024

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain

Rado
Author

Working in the web hosting industry for over 13 years, Rado has inevitably got some insight into the industry. A digital marketer by education, Rado is always putting himself in the client's shoes, trying to see what's best for THEM first. A man of the fine detail, you can often find him spending 10+ minutes wondering over a missing comma or slightly skewed design.