29
Dec
07

301 Redirects Using .htaccess File

First of all, this only works on web servers running on Linux, like Apache. It’s no good on a Windows server, which stinks, because I think this is the best way to do redirects because you can manage all the redirects on your entire site from one file, and you don’t actually have to create files and directories or leave old ones in place in order for those urls to be redirected.

Here’s the basic code you’ll put in your .htaccess file, which either should already exist in the root directory of your website (“root directory” meaning the home directory of your website, where your homepage file is located) or which you’ll need to create:

RewriteEngine On
RewriteRule ^directory/youroldpage.html$ http://www.yoursite.com/directory/yournewpage.html$1 [R=301]

Of course you would replace “directory” with the directory structure of your own site, and “yoursite.com” with whatever your site is and “yournewpage.html” and such with your pages.

Once again, the SEO reason why you want to use a 301 redirect is because it tells the search engines that this is a permanent change in the location of the content, and so the search engines will de-index the old page, index the new page, and pass the value of the old page onto the new page.


1 Response to “301 Redirects Using .htaccess File”


  1. 1 Jordan Kasteler Jan 2nd, 2008 at 8:11 am

    Yes, IIS for Windows sucks. http://www.isapirewrite.com/ can help cure some of the woes.

Leave a Reply




local business directories

Linkage