“301” Redirects for SEO

Mar 4, 2010 | Website Development

Search engines will often regard www.example.com and example.com as two different websites. Because of this, websites usually experience the effects of link fragmentation (inbound links point to both www.example.com and others to example.com). For example, if www.example.com has 5,000 inbound links and example.com has 2,500 inbound links you could potentially combine them so you have all 7,500 links pointing to www.example.com.

To do this you can setup a permanent “301” redirect by creating a .htaccess file with the below code. This will ensure that all requests coming in to example.com will get redirected to www.example.com.

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ https://www.example.com/$1 [r=301,nc]


  • The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
  • REPLACE example.com and www.example.com with your actual domain name in the code above
  • This .htaccess redirection method only works on servers using the Apache Mod-Rewrite module

This “301” redirect method is also a great way to save money on SSL certificates. When the site always points to www.example.com you only need to buy a single SSL certificate.