.htaccess Redirect From One Domain to Another Domain

To redirect traffic for all URLs of a domain to another with a permanent redirect (301) using a .htaccess file below are the steps.

  1. First, open a text editor, e.g. notepad, and create and save a file called .htaccess (be sure to change the file type to ‘All Files’ not ‘Text Documents (*.txt)’)
  2. Next enter the below code:
  3. Save the file and upload it to the root directory of the web server for the old domain

This should now redirect all traffic to any link that was on that domain to the same URL but with the new domain name.