Using URL rewrites and 301 redirects to optimise your site structure
Building on my last post about SEO Friendly 301 Redirects I’d like to explain a bit more about when these should be used, and how you can use them to overhaul a poor site structure without losing your pagerank or link strength.
The basic explanation to these is that a 301 redirect is known as a permanent redirect, this means that the 301 code is served in the http headers to your browser by the web server, letting it know that the page that was previously at this address has moved permanently to a new address. A URL rewrite basically allows people to access your content through a different URL, handy for changing the structure of a site if you wanted to move to more SEO friendly URLs for users and search bots to access via. These should be used in conjunction to avoid any loss of rankings or incoming links going to 404 pages when content is moved or restructured.
Now, lets look at a practical example of how to go about doing this for a very simple site that wishes to change to a more SEO friendly structure:
travel.com
|- 10241.html
|- new
|- 6316.html
This is a very simple site at travel.com containing 2 html pages that are not descriptively named, one inside a directory named new. Now lets say the file 10241.html is about holidays in Africa, and the new folder contains european holiday destinations, of which 6316.html is about spanish villa holidays. I’ll now show you a .htaccess file which will URL rewrite these to search engine friendly and user friendly URLs, then setup 301 redirects from the old pages so no pagerank or link juice is lost. Anything on a line beginning with a # is a comment
.htaccess
# All htaccess files doing rewrites should begin with these 3 lines
Options +FollowSymLinks
RewriteEngine On
RewriteBase /# rewrite rules
RewriteRule 10241.html holidays-in-africa.html [R=301,L]
RewriteRule new/6316.html https://www.travel.com/european-holidays/spanish-villa-holidays.html [R=301,L]
You would then change your directory structure to the new layout as follows:
travel.com
|- holidays-in-africa.html
|- european-holidays
|- spanish-villa-holidays.html
Any links to the old pages would get redirected to the new pages so visitors would not receive any 404 errors, as well as all of the pages pagerank moving to the new location. This also avoids duplicate content issues that would occur if you simply copied the files to the new locations.
This is just one way to greatly optimise your site for search engines and to improve user experience. It should also make your life easier as you will be able to see at a glance what file represents what content on your site. A previous post we have made comments on the effectiveness of using keywords in domain names which is worth a read if you would like more convincing!