AnOwnSite header

How to easily use htaccess to redirect browsers to another page


The easy htaccess redirect solution

You can easily use htaccess redirects to send browsers to another page than they requested.
Why would you do that?
Well, as your website grows, you will undoubtedly replace certain pages by others. Still, the old pages will be indexed in the search engines and generate (some) traffic. So deleting them would be a waste.

Of course you can use a HTML redirect <meta http-equiv=refresh content="0; url=http://www.just-an-example.com>, but search engines don't seem to like them because of the abuse.

So here's how you permanently redirect browsers using htaccess redirect coding.

Open your .htaccess file using a simple text editor.
add a line for each page that you want to redirect, as follows:

redirect 301 /olddir/oldpage.html http://yoursite.com/path-to-newfile.html

Note: I had to write this in small font to get it on one line.

When redirecting a page, you have to specify the directory or directories it is in.
So, a page in your root directory would be specified by /pagename.html, but a page in a sub-sub directory must be specified as
/subdirectory/sub-subdirectory/pagename.html.

The new page must be specified with its full URL.

And that's it. Easy he, htaccess redirects?


Click to return to htaccess possibilities