Because of popular demand from the forum, this is a tutorial on creating a 301 redirect. For those of you who don’t know, a 301 redirect is a way redirect visitors to another page and to tell search engines that the content is permanently moved. A 301 redirect is the most search engine friendly redirect because it will pass the most authority from the old page to the new page. For this tutorial we’ll assume that your website is on a Linux server (for the htaccess example).
PHP 301 Redirect – The PHP 301 redirect is popular because it’s an easy way to move a single page. Simple create a PHP file and paste this code into it for the redirect
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: https://example.com/newpage"); ?>
htaccess 301 Redirect – 301 redirects through a directory htaccess file are also popular because this allows you to redirect all the pages in entire directories without having to go through each file. You would use an htaccess redirect if you change domains or your URL structure. (There is no reason to use an htaccess redirect for a single file). Paste this code into your htaccess file for a directory-wide redirect
Redirect 301 / https://example.com/new/
You can also use htaccess redirects to redirect all WWW pages to non-WWW or all non-WWW pages to WWW if you have a preference. I recommend you pick one and stick to it.