How to Set Up a 301 Redirect in .htaccess

A 301 redirect is a permanent redirect from one URL to another. You can set up a 301 redirect using the .htaccess file on your web server. Here are the steps to set up a 301 redirect in .htaccess:

  1. Connect to your web server using an FTP client or file manager.
  2. Locate the .htaccess file in the root directory of your website. If the file doesn’t exist, create a new file and name it .htaccess.
  3. Open the .htaccess file in a text editor.
  4. To set up a 301 redirect, add the following code to the file:
Redirect 301 /old-url.html

Replace “old-url.html” with the URL of the page you want to redirect, and “” with the URL of the new page you want to redirect to.

  1. Save the changes to the .htaccess file.
  2. Test the redirect by entering the old URL in a web browser. The browser should automatically redirect to the new URL.

Note that the Redirect 301 command only works for individual pages. If you want to redirect an entire directory or domain, you will need to use a different command, such as RewriteRule.

Also, be careful when making changes to the .htaccess file, as incorrect syntax can cause errors on your website. Make a backup of the file before making any changes, and test the changes thoroughly before making them live.