Force non-www version for all sites on your account Updated on September 6, 2022 by Scott Mitchell 1 Minutes, 5 Seconds to Read When working with redirects in your htaccess, you are able to do specific things such as force a www or non-www version of your site. But since the .htaccess file is recursive, why not have some code that you can create once and have it work for all the sites on your account? This article demonstrates how you can force the non-www version of all sites on your account with a single piece of code. Don’t have time to read our full article? Watch our walk-through video. Force non-www on all sites on your account Log into your cPanel dashboard. Click on the File Manager icon located in the Files category, selecting the Web Root as the location. From the web root (public_html folder) open the .htaccess file for editing. If one does not exist, create a new one, then open the blank file for editing. Once the file is open, paste the following code at the top of the file: RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L] Save the changes to the file. Now you can test the code by visiting the www version of your site. It should redirect in the address bar to the non-www version.Share this Article Related Articles How To Create a PHP Redirect (301, 302, and Dynamic Redirect Examples) Connect to SFTP for Shared Hosting Accounts Using FileZilla FTP Basics for Dedicated Servers How to Install Jekyll and Launch a New Site How to Host AI-Prompt Generated Websites on Shared Hosting What is your default PHP.ini file? Getting Started Guide: FTP Configuring your site in WS_FTP Schedule Social Media Posts With Buffer FTP Error – 421 Too Many Connections