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
2,723
Replies
7
Views
4,427
Replies
6
Views
3,624
Recommended 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