Sometimes we need to change our URLs for certain reason eg for changing the page name from index.html to index.php or changing domain name for using our keywords in them for ranking, Just renaming them will not serve our purpose because old pages will still be available for user and they will get 404 error pages for those renamed pages, worst is for spiders they may get lost in such case.
The solution for this is to use redirects. We can implement the change in name without affecting SEO by using redirects such as 301 redirect or 302 redirect.
301 Redirect ( Permanent redirect ) :
It is best method for redirecting. It tells spiders/visitors that the requested page has been moved permanently at a new specified location. Implementing 301 redirects is very risky job, if anything gets wrong while using 301 your site will get out of search results, there are many webmasters who have suffered.
There are several methods of using the 301 redirect, you can use redirect in PHP, redirect in ASP, redirect in ASP .NET, redirect in JSP (JAVA), redirect in IIS, redirect in ColdFusion, redirect in CGI/PERl , redirect with mod_rewrite and finally the one I find most useful, the redirect using htaccess.
# 301 Redirect using .htaccess : ( On LINUX server )
Using htaccess to accomplish the 301 redirect is highly suggested due to it being fairly convenient to manage, rather than setting redirects on each individual page, you can simply add the redirect code to the .htaccess file.
# 301 Redirect for IIS : ( On Windows server )
In Internet Services Manager, right click on the file or folder you wish to redirect. Select the radio titled “a redirection to a URL”. Enter the redirection page, check “The exact url entered above” and the “A permanent redirection for this resource”. Click “Apply”.
302 redirect ( Temperory redirect ) :
It can be considered as a command line invitation for getting your site banned, since search engines don’t like temporary redirects.