301 (permanent) redirects are very useful when you have moved your content to a new location. By setting up a 301 redirect, we can ensure that visitors and search engines are directed to the correct page.
If your site is hosted on a server running Apache, the simplest way to create 301 redirects is using the mod_alias Redirect directive.
Using The Redirect Directive
You can add this directive to the
.htaccess file located in your website’s root directory. The Redirect directive syntax is:
Redirect [status] [URL-path] URL
status argument is not provided, the redirect will be 302 (temporary) redirect, which indicates to the client that the resource has moved temporarily. Provide the
URL-path argument with a path that will be redirected (beginning with a slash). Provide the last
URL argument with your destination URL.
Redirect a Page to Another Page on the Same Host
Redirect 301 /oldpage.html /newpage.html
Redirect to a Page on Different Host
Redirect 301 /oldpage.html https://www.example.com/newpage.html
Redirect an Entire Site to a New Site
Redirect 301 / https://www.yournewsite.com/