You own a website, some days later you started an another one and now you want to redirect the older website to a newer one without getting in trouble with the search engines.
If this is the case then you desperately want to do either one of these two things- homepage redirection or complete redirection.
In both, we’ll be carrying out 301 redirection, one by adding a simple php code while other is by re-configuring the web server file. It’s easy, don’t worry!
Redirecting website homepage to another
301 redirection means you’re moving to a new domain(new website) permanently, its a search engine friendly way of redirecting a website without losing any pagerank or getting in trouble with search engines.
Here is the simplest way of doing 301 redirection of a website to another,
<?php Header("Location: www.cyberpassion.com"); ?>
Place this code in the index.php page of the website you want to redirect. If the above written code is placed on the homepage of my website(yourravi.com) then visitors would be automatically redirected to cyberpassion.com.
Redirect all older urls to newer ones
You might want to redirect all older urls to newer ones, this can be easily done by a few modification in the .htdocs file of the web server. You’ll find .htdocs file in the root directory i.e directory where index file is present.
Here is the code,
Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.cyberpassion.com/$1 [R=301,L]
Add the code to the .htdocs file replacing cyberpassion.com to anything of your choice and save it. From now onwards, when someone visits url, directory or any other page of your older website then he’ll be automatically redirected to the respective url on a newer website.
Initially, this might appear a bit confusing but once you do this, it would appear a lot easy task.