An htaccess file is a simple text file that you can create using a text editor like NotePad. htaccess allows simple management of web server configurations.
htaccess uses redirect to look for any request for a specific page and if it finds that request, it forwards it to a new page you have specified:
Redirect /oldpath/oldfile.html http://mysite.com/newpath/newfile.html
Note that there are 3 parts to that, which should all be on one line :
The Redirect command (or Redirect 301), the location of the file/directory you want redirected relative to the root of your site (/oldpath/oldfile.html = mysite.com/oldpath/oldfile.html) and the full URL of the location you want that request sent to.
Each of the 3 is separated by a single space, but all on one line. You can also redirect an entire directory by simple using:
Redirect /oldpath http://mysite.com/newdirectory/
Using this method, you can redirect any number of pages no matter what you do to your directory structure. It is the fastest method.
Redirect individual pages:
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
This code will send visitors accessing “oldpage.html” to “newpage.html” instead.
Redirect all files in a directory:
Redirect 301 /mydir http://www.mysite.com/
This code will direct visitors accessing any file in the directory, “mydir”, to http://www.mysite.com/.
Redirect whole site:
Redirect 301 / http://www.new-site.com/
This code will direct all visitors to any page on your current website to http://www.new-site.com/.