This tutorial shows how to Redirect pages with htaccess, in this turotial we deel with two types of redirects. The temporary redirect and the permanent redirect.
It can be important that we redirect pages that has been moved, so that we do not lose visitors. That is where the permanent redirect comes in.
When performing redirects in htaccess, you can either use Redirect, RedirectMatch and you can use mod_rewrite.
Used when a page is moved permanently, often used when changing domains, or changing the site structure.
Redirect 301 /old-page.html http://www.example.com/newpage.html
Redirecting the whole Site:
Redirect 301 / http://www.example.com/
Note. When wanting to use the Temporary Redirect, simply change 301 to 302.
Redirect 302 / http://www.example.com/
If you have changed the file extension of a page, for example to .php from .html, you can use a regular expression to remember the file name, and redirect to the new file extension.
RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php
Note. The content of the parentheses is remembered, or back-referenced. The . dot allows any character, and the * asterix allows none or more characters to be present.