Search Engine Optimisation involves understanding many techniques and one such technique is the use of the .htaccess file in the creation of redirects. Here we will look at one very important type of permanent redirects and that is the 301 redirect.
A 301 redirect indicates and works as an instruction at server level telling that a web item has changed location permanently. The instructions contained in a 301 redirect indicate the previous location, the new/current location and identifies the change as permanent change.
The change may involve a change in your domain name, the name of your webpage, the path location of a webpage on the site or a path indicating that a page has moved to a different source.
How to safely move a web page and not damage its SEO rankings
When duplicating content to a new server or domain name, there are several considerations and precautions that you need to take in order to ensure success in the process.
First, do not duplicate the content to a new location and at the same time make changes in the file structure of your site. This is more likely to result into a mess. Therefore, take a systematic (one at a time) method as you check to see if you need to make changes and determine what changes are necessary at every stage. Again, before making any changes, consider factors such as functionality, user friendliness, accessibility, SEO and others that the changes involved might affect.
Make sure that you duplicate all the files involved and their structure since this helps you to avoid losing ranking since the search engines have already index your old URL. For instance, you might be moving from one domain name to another. In such a case the change in the domain name will have to appear in this manner;-
In the case above, you see that the catalog remains intact. It is therefore not advisable to change the catalogs at the same time as the domain name. Only do so when it is very necessary, for example, when the catalogs do not make any sense after changing to the new URL or domain name. If possible, try and keep the page names of your website and the folders included in the URL the same, this will help with 404 errors and rankings.
It is necessary to download files from the old server and save them on your desktop for convenience when uploading them to the new server. You can then upload the files to your new server. In cases where your move involves a database or dynamic files you may opt to either export the data base or download and upload it to the new platform.
How to create a .htaccess file for redirecting an old page to a new page
The .htaccess file is an important file in your website as it is the first file that the browsers used by your site visitors encounter and fetch. It contains instructions relating to the structure of your server, files, resources and other features of your site. You can see the .htaccess file by logging in to your web server through FTP. If there is no .htacess file, try creating one.
When creating a .htaccess file, use a code editor like a Notepad. Whichever code editor you choose, be careful that the file does not have any extensions to it like .html, .xml, .doc, .txt or any other file extension, the file name must be ‘.htaccess’ only. Notice the dot before the name htaccess. In case you forget to put the dot before ‘htaccess,’ then, your file will not work. If you found .htaccess file when you logged in to your web server, download it and edit it using a code editor to include the details shown below.
Page redirection, 301 code how to change the .htacess file
- Include this code in the .htaccess file
redirect 301 /old/old.htm http://www.newdomain.com/somefile.html
- When you download your .htaccess file, position the code above the file’s bottom. Separate the old address and the new address with a space.
- Save your .htaccess file and be careful that no extensions like .txt or any others are included as this might change the file format and therefore it won’t work as a .htaccess file
- Upload the new .htaccess file to the root folder of your site.
- Test that it is working by entering your old URL in a standard web browser address bar and if the redirect was successful, your will land on the new URL home page/page. Clean your browser’s history if it doesn’t work the first time.
What makes the use of a 301 redirect necessary?
There are several reasons that might require the use of a permanent 301 redirect. Such reasons include:
- Having only a singe version of a website, whereby all other domains are redirected to the main domain name.
- Dealing with duplicate content, since you need to redirect visitors to your new location.
- If there is migration or change from one domain to another.
- Owning multiple domain names such that you buy a .com, .net, .org, .uk, domains so that there are no duplicate/imposter websites and then you redirect all these domains to the preferred domains permanently.
- After a website reconstruction which can be an overhaul of the entire site or migration to a new technology, for instance from HTML to PHP.