How to force away from / to www

There are many ways to force www/non www, but this way requires to create/edit .htaccess file (htdocs/.htaccess or yoursite.dom/htdocs/.htaccess)

Forcing away from www.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yoursite.dom [NC]

RewriteRule ^(.*)$ http://yoursite.dom/$1 [L,R=301]

                                          ^^ changing that to https forces away from www. and also forces https encryption

Forcing to www.

Its basically the same thing

NOTE: If you are using a Free Subdomain like site.rf.gd, DON’T USE THIS!

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.dom [NC]

RewriteRule ^(.*)$ http://www.yoursite.dom/$1 [L,R=301,NC]

                                          ^^ changing that to https forces www. and also forces https encryption

7 Likes

Shd be…

You left out www

2 Likes

Force HTTPS redirection | Hosting KnowledgeBase is probably better and more generic

That’s for something different, and it’s already been covered in the Documentation.

The community guide is intended to help user go to / from www.

3 Likes