How to use .htaccess redirects

Time to Read: 5 minutes Difficulty Level: Beginner
Tools Needed: access to edit files on your site, eg: via FTP or directly within Plesk Last Updated:

What is a .htaccess file?

An .htaccess file is a file that alters the configuration of the folder it is placed in, and all the sub folders underneath it. It is a method of controlling the configuration of your web space when you do not have server admin privileges and cannot make server-wide changes (or when you do have server admin but you don’t want to affect the whole server!).

The file begins with a . because it makes the file hidden by default – as the files determine how your site functions, it is important that the file is protected. The .htaccess file can be used to configure external redirects and internal URL rewrites, as well as for restricting access to certain pages via (for example) IP address or user-agent. Several instances of .htaccess are used throughout the file structure to change the configuration at specific levels. There are many tutorials available online explaining how to use .htaccess.

Using 301 redirects

Using 301 redirects

A 301 redirect is a method of redirecting one web page to another, without losing any of the search engine benefits that page may already have accumulated – so if your old page is on page 1 of Google, it remains there and people clicking on it are redirected to your new page.

You could consider using a 302 redirect to tell search engines that the redirect is temporary. Then you can update your rule to a 301 when you’ve confirmed you’re happy with how it’s functioning.

The following code will redirect a single page (as opposed to all pages of your site) to a new URL. Note that this will only redirect the specific old/old.html page to the new URL. In order to make this a 302 redirect you would just need to edit the number after “Redirect”:

Redirect 301 /old/old.html