How To 301 Redirect Non WWW URLs to WWW URLs Via .htaccess ?

Without using any automatic hosting feature (and then waiting) you can directly edit .htaccess file and quickly redirect all your non-www URLs to www URLs.

Visit your website’s file manager from cPanel, open .htaccess file and add the following given code changing example.com to your domain name:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

This will 301 redirect your website’s non-www URLs to www URLs.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.