Search Knowledge Base
Table of Contents
< Go Back To Home

Force www in your .htaccess file in cPanel (For WordPress & All Sites)

At times, customers may ask to have either the www or non-www version of their website displayed in their visitors’ browsers. For instance, they might want or simply to appear in the address bar. Although this choice doesn’t impact how visitors discover the site, it can be a matter of personal taste. This article will walk you through the process of enforcing the www or non-www version in your .htaccess file. You can easily access the .htaccess file using the cPanel File Manager.

  1. Log into your cPanel hosting.
  2. Once logged-in, Find the Files category and click on the File Manager.
  3. Click on Settings tab at the top right corner of the screen.
  4. In the Settings Menu, choose the document root (or folder) for the domain you are working with and be sure the checkbox next to Show Hidden Files is checked. Click the Save button.
  5. Look for the .htaccess file and right click on it. Followed by a click on the Edit option.
  6. A new window will open in form of a text editor.
  7. Paste the below code to redirect your website from non-www to www:
#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301,NC]

IMPORTANT NOTE: Kindly change to your real domain name (without www). Example: or