To redirect from non-www to www host, just have .htaccess file on your root folder (/var/www/.htaccess) with following code.

#Force non-www:
#RewriteEngine On
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#RewriteEngine On
#RewriteCond %{HTTP_HOST} ^inheritxdev.net [NC]
#RewriteRule ^(.*)$ http://www.inheritxdev.net/$1 [L,R=301]
Options +FollowSymLinks
RewriteEngine on


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

FYI, this will basically force redirection of host.com to www.host.com

You may also like

Leave a Reply