301 redirect to new domain htaccess

To set up a 301 redirect from an old domain to a new domain using an .htaccess file, you can use the following code:

Redirect 301 /old-domain.com http://new-domain.com

This will redirect all requests from old-domain.com to new-domain.com.

If you want to redirect specific pages or directories, you can use the following format:

Redirect 301 /old-domain.com/path/to/page http://new-domain.com/new-path/to/page

This will redirect requests from old-domain.com/path/to/page to new-domain.com/new-path/to/page.

You can also use regular expressions to match patterns in the old domain and redirect them to the new domain. For example:

Redirect 301 ^/old-domain.com/(.*)$ http://new-domain.com/$1

This will redirect all requests from old-domain.com to new-domain.com, preserving the path and query string.

Make sure to update the old-domain.com and new-domain.com placeholders with your actual domain names.

Here are some additional tips:

Here is an example of a complete .htaccess file with multiple redirects:

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Redirect old domain to new domain
  Redirect 301 /old-domain.com http://new-domain.com
  Redirect 301 /old-domain.com/path/to/page http://new-domain.com/new-path/to/page
  RedirectMatch 301 ^/old-domain.com/(.*)$ http://new-domain.com/$1

  # Other redirects...
</IfModule>

Remember to update the old-domain.com and new-domain.com placeholders with your actual domain names.