.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory and all subdirectories thereof.
In general terms .htaccess is used to redirect your website to any other web address, that means it redirect or transfer the whole site address or any particular web page to other address or website.
if u have 2 or more sites / URLs you can redirect your one site to other web address. you can understand it from this example used to redirect a site made in PHP language and hosted at LINUX Server.
Example for Sites hosted on LINUX Server in PHP Language :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^http://greenparadize.com/
RewriteRule (.*) http://www.greenparadize.com/
/$1 [R=301,L]
After writing this code in a text file or notepad just save that file named as .htaccess then upload this file in your hosting panel.