Your website has been using a certain domain name for a while now, but so it happened that the domain name you always wanted has become available and you got it first. Now you ask yourself, will my website lose all backlinks when I change the domain name? The simple answer is no, but a proper redirect needs to be done.
A redirect is an information for both users and search engines which sends them to a different URL than the originally requested. The 301 redirect informs the visitor that the website has “moved permanently”, and 302 redirect says “found” or “moved temporarily”.
How the 301 redirect functions? It is an HTTP status code “301 Moved Permanently” that signals the visitor to the page which is been moved permanently to a new URL. We have to note that with 301 redirects the inbound links value, as well as trust records of the URL, will transfer to the other, confirmed by Matt Cutts, Google’s head of Webspam.
For most cases, you need to contact your website hosting company for the implementation of the 301 redirect, which will add the redirect HTTP code. However, for WordPress website, there are a number of free plugins, such as “Simple 301 Redirects”, which can enable you to set up and manage 301 redirects.
Search engines take time to process data. You have to maintain the old website while making the HTTP301 redirect to the corresponding page. Backlinks will still function and with a bit of time, Google will recognize that both domains are the same website.
While you may lose some search ranking initially, until the search engines index the new website properly, it has overall very small short-term effect. The 301 redirect is in effect while you own both domains, and you must not let the domain lapse, so be prepared for a longer transition period.
We can conclude that 301 redirect is a functional and easy way to permanently move a website from one URL to another, but it can also be used to “lose” the www from the domain name too.
An example of PHP redirect would look like this:
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.new-url.com” );
And a Java (JSP) redirect code would look like this:
response.setHeader( “Location”, “http://www.new-url.com/” );
response.setHeader( “Connection”, “close” );
But you also need to know were to insert it in your files, and need to make sure it is done properly, which is why we would suggest asking your hosting company to give you help with it.