Redirect non-www to www using .htaccess file : step wise process

According to SEO Techniques If your website has positive effects then your website's redirction should be on www. Some users are aware of this, but some users do not know about how they force their website from non-www to www.To redirect non-www to www or say that force your website using the .htaccess file. With the help .htacess file you can easily redirect non-www to www.

We like to use technology and write on technology. By using technology, you make your life easier. If technology is used well, then you make life better. All you need to do to work on technology.

Here we are talking about how you can redirect a website from non-www to www. Security is very important for all websites. You can get a free SSL certificate for your website. After applied SSL certificates on your domain, you have redirect HTTP to Https.In the same way, you have to force your website to www.

How to redirect www or non-www .htaccess files.

The www formate is standard formate. If you are running a website on a global server, then you should use this standard formate. When you buy a domain, you get your options where you have to choose.To redirect non www to www,we need to focus on googleChange page URLs with 301 redirects.

1.www redirection

2. Non-www redirection

You can choose www or non-www while managing the domain.

Non-www Redirect -

The non-www means that you are not forcing your website at www redirection


Example of non-www URL -

www URL (redirection)-

If a website is redirecting from non-www to www using .htaccess file and it is redirecting to www. That is known as www redirection.

Example of the www redirection standards -

Let's implement redirection process. There are two method two edit a .htaccess file to redirecting non www to www.

1. Create .htaccess file and upload on your server.

I. Open notepad on your local system to create a htacces file. You can use notepad++ text editor ,sublime text editor or etc.

II. Open new file. When you open a new file a blank window opens on front of you. You can do any code on that.

II. Save the file with the name " .htaccess" . Never forgot the dot(.) before htaccess.

IV Create a code for redirect nonwww to www standared formate of domain.

V. Now upload on your website root folder. Never upload .htaccess file on another directory or subdirectory. The .htaccess file should be uploaded on the root folder.

2. Edit existing .htaccess file for redirect non www to www

On the server , a existing .htaccces file can be edited.You have to look for it.

I.Login your website cPanel.First of all, login your website cPanel.

II. Click on file manager.You will get all information about your domain or domains in file manager. Change kind of file using file manager.

II. Choose your domain.

III. Visit public_html folder.The public_html folder contains domain files.This is known as root folder of website.You can change,edit and delete kind of files here.

IV .Search for .htaccess file.

V. Create a redirect code for non-www to www.

VI .Save htaccess file .

VII. pen your website URL on broweser.

Redirecting non www to www using htacess file code.

If you are created a .htaccess file on your root folder then add this code.

Non secure http-www

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Secure https-www

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTPS}s on(s)|offs()
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]

In this way, you can redirect your website traffic to secure https www connection.
More Reference-
Redirect http to https

Please Share

Recommended Posts:-