Search Our Database

How to Add WWW to Your Website Using .htaccess?

Last updated on |
by

Introduction

Certain websites have www displayed in their URL, and some do not. It makes no real difference whether you choose to add www in front of your website, or not, aside from cosmetic reasons.

This guidance will go through the step of configuration.

 

Prerequisites

  • SSH access to server
  • Knowledge on Linux command

 

  1. SSH into the server.
  2. Type command below to gain root access.
    sudo su -
  3. Locate your website folder (public_html).
  4. Edit the .htaccess and add in below line. You may create new .htaccess if you currently didn’t have it.
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^example.com [NC] 
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  5. Your website URL should be showing WWW now.

 

Conclusion

By following the guidance above, you should have managed to configure your website URL to show WWW.

 

For additional assistance or if you encounter any issues, please contact our support team at support@ipserverone.com.