kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Redirecting non-www to a www prefix

Posted on May 22, 2010

This old chestnut again.

Create or edit the .htaccess file

  1. RewriteEngine On
  2. RewriteCond %{HTTP_HOST} !^www.YOURDOMAIN.COM$ [NC]
  3. RewriteRule ^(.*)$ http://www.YOURDOMAIN.COM/$1 [R=301,L]

Related posts

  1. Redirect a www prefixed site to a non-www prefix
    I like clean URLs. Add this to your .htaccess in the site root RewriteEngine on...
  2. [Snippet] Redirecting Non-SSL Traffic to SSL
    ...
  3. Apache redirects based on IP Address/Subnet
    Ever needed to redirect a source IP address or source subnet in apache? Why? Redirect...
  4. .htaccess redirect based on requested domain
    Imagine you have a selection of domain names that point to the same site, are...
  5. mod_geoip Revisted including stopping spam in phpBB 2
    I've recently moved a client's forum onto a new cPanel server, previously it was on...

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.