301 Redirects with .htaccess files on Linux Apache

At some point, it may be necessary to reorganize a website or move a website to a new domain name. This means that your pages will no longer be accessible via their previous urls, resulting in a lot of 404 – Not Found errors for all visitors and search engines that request these pages.

While this might not appear like a big problem given that users can still find information using your site’s navigation of search features, this is indeed something that can seriously hurt your website, both in terms of traffic and search engine ranking.

Why Page Not Found Errors Are Bad

When visitors come to your website and are unable to find what they are looking for, they do either one of two things: leave right away or continue to look for information on your website. This is not a choice that you want visitors to make, as it will result in loss of traffic. Another consequence of ‘bad links’ or ‘missing information’ is that visitors might think of your site as unprofessional. But this doesn’t stop at human visitors.

Search engines are also affected by these errors. When it finds such a page that is missing, it drops it — along with any accumulated pagerank — from its indexes. And as pagerank takes time and effort to accumulate, losing pagerank can be very costly.

But Here’s A Solution!

Fortunately, you can avoid these costly errors by employing redirects. Redirects avoid Page Not Found errors by serving the appropriate content, even when an old and non-existent url is used.

Additionally, search engines are redirected. In the process, they are also told one key bit of information: that these pages are being permanently moved. This is the key to preserving any accumulated pagerank. By serving 301 redirects, search engine are told to drop the old urls from their indexes and replace them with the new urls.

Hot To Add It To Your Website

There are many different ways of adding 301 redirects, however using an .htaccess file requires the least bit of work and is a seamless way of redirecting users, so this is the method that we suggest. And as you will see in the examples below, this is very simple to accomplish.

Note: You will need a text editor such as WordPad or NotePad, or some other program that allows you to save text files using uncommon file endings.

Sample Code:

⇒ Using .htaccess to redirect certain pages

Redirect 301 /oldpage.html http://www.yourdomain.com/newpage.html
Redirect 301 /oldpage2.html http://www.yourdomain.com/newfolder/

⇒ Using .htaccess to redirect an entire website

Redirect 301 / http://www.newdomain.com/


Once done creating your .htaccess file, be sure to save it as .htaccess and upload it to the root folder of your website. (Note: HTACCESS is not a name, but a file type. If you are unable to save it this way, try uploading it to your server as a text file, and renaming it once there.)

To see more of what .htaccess files can do, check out our article Custom Error Pages with .htaccess Files.

Tags: , , , , , ,


Trackback URL:

Leave a Reply

Want us to work on your project?

Contact us today for a quote. Click here to submit details regarding your project.

If you are making a general inquiry, send an email to info@velvetblues.com

Go Daddy Deal of the Week: Cheap .COM Domains! Offer expires soon!