You have had your site for sometime and now it is time to make some changes to it to keep it on par with the ever fast moving technology. Thus, you decided to upgrade your site or moved it to an entire new domain. Maybe, just started using Search Engine friendly URLs or just decided to move one document to a new location. Bottom line a document or a directory that was at location “Old-URL” has been moved to “New-URL” and therefore not accessible at the “Old-URL.” This can greatly effect your Page Rank and undo all the hard work you have put into Search Engine Optimization (SEO). Moreover, all the URLs linking in to your site from external sources, such as emails you sent, links you shared on social media websites, and any place you published those link are now broken.
I would like to emphasize the importance of redirecting “Old-URLs” to the correct “New-URL” by explaining what happens behind the scenes between the Search Engine and your Server. When a Search Engine crawls your site and comes across a document that is no longer available it receives a 404 document not found error. While 404 signifies that the document has been temporarily removed, if the page is re-crawled and the error persists the document will be removed from the Search Index within 30 minutes.
To overcome the above mentioned problems you can use URL Redirects. This will tell the Search Engine where the documents have been moved to. In fact, you can provide more information than just the new location of the document. You can indicate whether the document has been moved permanently with “Redirect Status (301)” or “Redirect Status (302)” if the move is temporary. If the document is replaced with a different document you can use the “See Other Status (303)” and if the document has been removed completely use “Gone Status (410).”
Using 301 redirects you ensure that all the previous “Old-URLs” are mapped to the appropriate “New-URLs.” Furthermore, when a search engine crawls your site and comes across a document that has been permanently moved (301 Redirect), it change the status of both “Old-URL” and “New-URL” to New Document in the Crawl Diagnostics page. The “New-URL” then appears in the In the search results page.
The easiest way to achieve this is by using htaccess redirect. The code has 4 components:
Redirect command, status code, old URL, new URL all separated by a single space.
<IfModule mod_rewrite.c> RewriteEngine On Redirect 301 Old-URL-1 New-URL-1 Redirect 301 Old-URL-2 New-URL-2 ... </IfModule>
Another way is to redirect using PHP. For this you will need to use the header function in PHP. The header function takes 3 parameters. You must provide the “New-URL”, indicate whether the header should be replaced and the Redirect Code and therefore the redirect code will be:
<?php header("Location: New-URL", true, 301); ?>
By utilizing the Redirect feature of the server you can modify or move your site without disappointing your users by showing them a 404 not found page, or harming or resetting your SEO process. You can easily avoid broken links and keep your Page Rank unchanged.
Before you leave, I would like to remind you to update your sitemap.xml file accordingly.