Sometimes we need to change the URL of pages, but it is a risky task, because
if your pages are already indexed in search engines, you will lose not
only visitors but also your SEO ranking. Your indexed URLs will start
to disappear one by one, forcing you to start from scratch again
If you need to change the URL of a page as it is shown in search engine results, we recommend that you use a 301 redirect. This is the best search engine and user-friendly way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location.
You can do it in your cPanel, in your .htaccess file, or in your php file. To perform a 301 redirect in your cPanel, under theDomains
heading click on Redirects
.To do a 301 redirection in your PHP file, put in this code in the old page:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.newdomain.com" );
?>
To do a 301 redirection in your .htaccess file, you may add in the following codes:
Redirect an old page URL to a new page URL:
Redirect 301 /old-page/ http://www.mysite.com/new-page/
Redirect root domain to new domain:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [NC]
RewriteRule (.*)$ http://newdomain.com/$1 [R=301,L]
</IfModule>