How To Redirect non-www to www URL with .htacess

Post a reply


This question is a means of preventing automated form submissions by spambots.

BBCode is OFF
Smilies are OFF

Topic review
   

Expand view Topic review: How To Redirect non-www to www URL with .htacess

How To Redirect non-www to www URL with .htacess

#3

by admin » Mon Apr 16, 2018 5:08 pm

eastatlantaniqqa wrote:
Sat Apr 07, 2018 2:00 am
I want to replace my. blogspot domain with a. com
domain please how do I go about it ?
Read this tutorial to get started
How To Change A .Blogspot To .Com

How To Redirect non-www to www URL with .htacess

#2

by eastatlantaniqqa » Sat Apr 07, 2018 2:00 am

I want to replace my. blogspot domain with a. com
domain please how do I go about it ?

How To Redirect non-www to www URL with .htacess

#1

by admin » Tue Mar 20, 2018 4:54 pm

Image
Sequel to the post made by @IPman on which is preferable between www and non-www URL.
When you set your preferred URL in Google webmaster tool, it is important that you link the chosen URL version to the one you didn't choose.
For instance, when you choose www.example.com as your preferred URL, you also need to redirect example.com to it (can be done vice versa), in order to prevent google from seeing your website as two which will make your contents to be seen as duplicate content and it will affect your ranking on search engine.
In this tutorial I'll show you how to set 301 redirect with .htacess of your website.

1. Redirect www to non-www
To redirect www to non-www URL version of your website, copy the code below and add it to the .htacess of your website.

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
2. Redirect non-www to www
To redirect non-www URL version of your website, copy the code below and add it to the .htacess of your website.

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Note: Replace example.com with your own URL

Please drop your questions below if any.

Top