How to redirect non-WWW traffic to WWW using Mod Rewrite

If you are looking to send people to, when they type in then you can use mod rewrite in Apache to get this done for you.

Use the code below in your .htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

4 thoughts on “How to redirect non-WWW traffic to WWW using Mod Rewrite”

  1. Hello Jake, thanks for sharing this tips, i never knew about this, Well, we have recently launched a contest for graphic designer. To enter into contest you must have 10 decent forum posts.
    We are looking for designers who can make the best vBulletin forum theme including logo with great exceptional imagination skills and you can win Dell XPS M1530 Laptop and more.

    Hope this might be of some interest to you.

  2. Heh, you steal this code from my remotv apache configs? jk

    It is actually safer to do it in the config files though.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: