Force www or non-www in htaccess?

Maxoq

Well-known member
Registered
Joined
Feb 25, 2015
Messages
520
Points
28
Many my friends at some point asked me ways to force either the www or non-www version of their site to display in their visitor's browser. For example we always use www.example.com or simply example.com display in our web browsers. There is a common thought that forcing one format is better for search engine optimization. I want to know there are some ways to perform this action in your .htaccess in the cPanel for my primary domains. Any guides?
 

LJSHost

Well-known member
Hosting Provider
Registered
Joined
Jul 5, 2016
Messages
1,031
Points
63
in your .htaccess file

#Force www.
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
 
Older Threads
Replies
5
Views
3,096
Replies
7
Views
5,092
Replies
6
Views
4,358
Latest Threads
Replies
1
Views
26
Replies
0
Views
188
Replies
1
Views
40
Replies
2
Views
83
Recommended Threads
Replies
8
Views
2,755
Replies
9
Views
12,266

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top