Be Found:
Using htaccess to control redirections

How to design findable web sites and get ranked with the best

The basics: understanding search engines and spiders

Index or directory?

Setting the right keywords

Using robot protocols to prevent unwanted indexing

Use core HTML tags more efficiently

Optimizing tricks to avoid

Getting dynamic web pages indexed

The problem of unreadable content

The commercial options for SEO

Using htaccess for efficient redirection

The final word on SEO

Using htaccess to redirect visitors properly

Here, I'll show how to control where people go in your site without disturbing automated indexing tools.

If you work with an existing site, it may have been visited by search engine spiders already. As such, it's best to avoid moving files and folders around or renaming things. However, sometimes this is unavoidable. If you simply move and rename things, when people try to follow search links to your site they'll get dead links. Spiders will also get the same result when they check back, at least until the new site structure has been found.

To avoid this, you need to have people redirected automatically when they try to visit the old pages. Not by using the 'refresh' meta tag, as this is a crude method that's frowned on by spiders. The professional method uses the standard Apache server redirect command. This is stored in a text file called .htaccess (the full-stop at the front of the name is important), and contains one or more lines that tell the server what to do when someone asks for certain files. This only works with Apache-driven sites, but that's what runs the vast majority of sites around the world. Work out what redirections you'll need. If you want to point requests for specific files to other ones, then list these by name, one in each line. If you want to redirect all requests for a directory to another one, list it first then the directory (or single file) to be used instead.

Don't try to name the file .htaccess on your Mac before uploading; the full-stop at the beginning tells Unix-based systems, including the Mac, that it's invisible. Instead, name it htaccess.txt and rename it once on the server. For full details, although admittedly fairly technical, on how to use the Apache redirect command and more, visit

ahtaccess1Set up htaccess instructions

Here, we set up simple htaccess instructions to redirect users. Begin with redirect permanent. This tells the Apache server what to do with the following data, and to tell visitors that the change is a permanent one. Then comes the URL, which someone might request, listed in local form with a leading slash, as in /file.html or /folder. Finally, supply the full replacement URL, including http://. So, to redirect a request for file.html at the top level of your site, use redirect permanent /file.html, and to redirect a whole folder (called 'directory') use redirect permanent /folder

bhtaccess2Upload the htaccess file

Now we'll upload the file and name it correctly. Save the text file as htaccess then use an FTP tool to upload it to the top-level of your Web site's directory structure, alongside your home page's index.html file. Once there, change the file's name to include the full-stop at the beginning of the name (remove any .txt filename suffix). Now the Apache server will check here before serving any pages, and requests for named items will be passed the correct replacements immediately.

redirect permanent /file.html

redirect permanent /folder

Looking for tips on searching more effectively instead? Read the Search Secrets pages.

Have you found the information on this site useful? If you like, you can make a small donation directly to my hosting bills! It would be deeply appreciated.