Knowledge Base

Get Expert Website Hosting

Choose website reliability and expertise with SiteGround!

Home / Website Help / Other / How to redirect non-www URLs to www?

How to redirect non-www URLs to www?

Last update: Mar 13, 2024

If you are using WordPress or any other domain name dependent application, you should first change the URL of your application to be with www. For WordPress you can do that by following the instructions here.

To redirect your website from non-www to www, add the following lines in your website’s .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]

Replace yourdomain.com with your actual domain name.

Share this article