Home Web Hosting Simple .htaccess www-redirect

Simple .htaccess www-redirect

by rigotechnology

If you are looking for a simple way to redirect the non-www version of your domain name to the www-version, then this .htaccess 301 redirect example may be of help to you!


  • You will need to be on a Linux web hosting account.
  • You will need the ability to upload a .htaccess file into the root folder of your website.
  • You will need a way to upload this file to your website’s root folder, such as an FTP Program of cPanel File Manager.

Special Notes: Joomla has a canonicalization plugin that works great for this type of redirect. Magento allows this to be setup in the “System > Configuration / Web / Unsecure / Base URL” area of the administration.

1.) Create a new file and name it “.htaccess” without the quotes.
2.) Edit the .htaccess file in WordPad, Notepad, or Dreamweaver.
3.) Paste the following code into the file.

RewriteEngine on
rewritecond %{http_host} ^yourdomainname.com [nc]
rewriterule ^(.*)$ http://www.yourdomainname.com/$1 [r=301,nc]

4.) Rename the two references to “yourdomainname.com” with your actual domain name.
5.) Save the file
6.) Upload the file to the root directory* of your website.


You may also like

Platform Slot Gacor CMS Checker