Redirect Techniques
You will find that when you have a website there will be the need to change it. Mostly this is a matter of updating the content of a page to keep it fresh. Often this is simply a matter of adding pages with new content correct URL redirect. These pages will be found by the search engines because the page is linked in some way to other pages on the site.
No effort needs to be done by the webmaster to make this happen. Sometimes however you will need to change the name of the URL to better reflect the keywords you want to link to the page and in doing so improve the SEO ranking. In extreme cases, it can also be possible that the whole site name needs to be changed.

Overview of redirect types
While your clients by and large will not have the option to differentiate between the various sorts of sidetracks, Google Search utilizes diverts as a solid or frail sign that the divert target ought to be accepted. Picking a divert relies upon how long you expect the divert will be set up and what page you need Google Search to show in list items (Source:01 )
- Permanent redirects: Show the new redirect target in search results.
- Temporary redirects: Show the source page in search results.
The accompanying table clarifies the different ways you can use to set up lasting and transitory sidetracks, requested by how probably Google can decipher effectively (for instance, a worker side divert has the most elevated shot at being deciphered accurately by Google). Pick the divert type that works for your circumstance and site:
What happens then is that the bookmarks that people have created and also Google will point people in the wrong direction i.e. to the old location of the site. As this no longer exists they will get an Error 404 and not be very pleased about it. To avoid disappointing customers and to also not have Google believe the website is out of control you need to tell these users where the new location is.
The best way to do this is by creating a redirect 301
This is a permanent redirect and tells the user where the new page is located. In order to have these correct URL redirect, the old page must still be active and contain the information whereto the page is to be linked.
In this way, the built-up value of the page can be retained. SEO-optimizers have seen many examples of especially large corporations which did not clean up after major site changes were carried out. As a result, they lost a lot of the value they had built up on their website and had to start again.
In addition, the overall quality score that Google allocates to the site suffers which additionally brings down the site. SEO-optimizers can support discovering where there are problems in this area and help to fix the redirect issues.

Here you can see the flow of the correct URL redirects from the initial queries to the server and back to the user.

If there is a choice you should use a 301 over a 302 redirect because on a 302 the rank page is not flowed through whereas on a 301 there is only a limited loss. Many companies forget to make the correct URL redirect altogether and of course, there is then a serious loss of PageRank.
What is worse is that the customers are treated to the dreaded 404 error. What additionally can happen is that the quality score of the site is reduced because of the number of bad link building that are present on the site as a result of this. You need to use a systematic solution to track down where on your site these errors are present and regularly eliminate these types of errors.

Redirect 404 to homepage
I tried this code, it doesn’t show 404 pages, but it shows the same URL but content of the homepage.
/*add this code in .htaccess file*/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.html [L]
How to Redirect a Page with HTTP 301 in PHP
HTTP 301 Redirect is an SEO well disposed approach to divert perusers to a page’s new area. There are a lot of advantages of utilizing HTTP Redirect. These advantages can be found in the htaccess technique post. htaccess or PHP can be both utilized for sending 301 sidetracks. The htaccess technique can be found in How to Redirect Old Domain to New Domain Using htaccess Redirect. This post talks about the strategy that utilization php to produce the HTTP 301 Redirect.
As an example, we will redirect a page to https://ozairwebs.com/ in PHP.
Add this code snipped in function.php file Or at the end of header.php
<?php
// Permanent 301 redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://ozairwebs.com/");
exit();
?>
Redirect http to https:
1. Redirect All Web Traffic
If you have existing code in your .htaccess, add the following:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ [R,L]
2. Redirect Only a Specific Domain
For redirecting a specific domain to use HTTPS, add the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ [R,L]
3. Redirect Only a Specific Folder
Redirecting to HTTPS on a specific folder, add the following:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ [R,L]
WordPress Redirection Plugin:
Create and manage redirects quickly and easily without needing Apache or Nginx knowledge. If your WordPress supports permalinks then you can use Redirection to redirect any URL.
There is full support for regular expressions so you can create redirect patterns to match any number of URLs. You can match query parameters and even pass them through to the target URL.
The plugin can also be configured to monitor when post or page permalinks are changed and automatically create a redirect to the new URL.
Download from WordPress Resource: Click here