Redirecting your website from non-www to www URLs can be as simple as adding suitable code in your .htaccess file.
For non-WordPress websites, you can use the code below replacing domainname.com with your own domain name.
# ensure www.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]]
Alternate code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domainname.com$
RewriteRule ^(.*)$ http://www.domainname.com/$1 [R=301,L]
For WordPress websites, this should be done by setting the URLs in your WordPress General Settings. Using the code above for a WordPress website can put it in a loop.
You can also force non-www URLs in a similar way by changing the code as follows. Again, this should be placed in your .htaccess file located in your public_html folder.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domainname\.com [NC]
RewriteRule ^(.*)$ http://domainname.com/$1 [L,R=301]
All our servers need you to enable outgoing SMTP server authentication to be able to…
Learn how to configure and check your DNS settings in Plesk. After you registered your…
This video demonstrates how to use the Force HTTPS Redirect feature. This feature allows you…
Use cPanel's MultiPHP Manager to manage your domains' PHP version. Being able to manage the…
This tutorial will help you to configure Microsoft Outlook 2016 for an email account. Step…
Generally emails are directly delivered to the destination server. However, if the delivery attempt to…