How to 301 Redirect Non-WWW to WWW URLs

Valic —  June 2, 2010 — Leave a comment

The simplest way of achieving this is by altering the .htaccess file in your websites root directory.

Download the .htaccess file to your computer using your favorite FTP client, open and edit it.

If you do not have a .htaccess file you can create one and upload it, look harder tough, these files are usually hidden.

If your website root directory does have a .htaccess file open it and first check to see if the rewrite engine declaration is posted: RewriteEngine On

If the Rewrite Engine is On then go ahead and add this following code to your .htaccess file:

Remember to backup your .htaccess file before you start editing it.

RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1

Remember to replace with your websites URL.

Upload the .htaccess file to your website, replacing the old one, and then try accessing your website without the www. If you are not automatically redirected to the www version then check your spelling and follow this tutorial from the beginning.


Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

No Comments

Be the first to start the conversation.

Leave a Reply