Setting 301 Redirect using .htaccess

There are often times during the development of a website when it needs to be reorganised and pages moved into new categories or folders. It may also be the case that pages from one website need to be transferred to another.

While such re-organisation may be beneficial to the look and feel of a website it can be problematic when pages have a presence in search engines for certain keywords. Once the page has been moved a user clicking on your listing in the search engine results will be directed to 404 error page.

The solution is to set up a 301 redirect in your .htaccess file. This piece of code tells Google and other search engines that the page has been permanently moved and they will update their records accordingly.

To set up a 301 redirect in your .htaccess file.

  1.  download the .htaccess file from your site
  2. open the file using notepad
  3. add the following code #User added 301 Redirects
    Redirect 301 /directory/file-name.html http://www.yourdomain.com/newdirectory/file-name.html
  4. save the file and upload to your website.

Leave a Reply

Your email address will not be published. Required fields are marked *