Add WWW PREFIX IN DOMAIN URLGo to your website’s home directoty: cd /home/username/public_html Open the .htacess file with any of your favourite editors: Insert the following code in file. RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainname.com
RewriteRule (.*) http://www.domainname.com/$1 [R=301,L] Save the file. Assign proper ownership to the file. This will redirect all requests to the non-www version of your site to the www version using 301. For Nginx users add the following code in domains server block. Remove WWW Prefix in Domain URLAdd the following code in your web server configuration. This will remove www prefix from site url. If some one opened site with www, this will redirect to non-www url. Apache users add the following code in your website .htaccess file. It will required the mod_rewrite enabled on your server, without mod_rewrite it will not work. Nginx users add the following code in domains server block. |