Redirect old domain to new domain htaccess

To redirect an old domain to a new domain using .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 the RedirectMatch directive to redirect based on a regular expression:

RedirectMatch 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.

Note:

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

Redirect 301 /old-domain1.com http://new-domain1.com
Redirect 301 /old-domain2.com http://new-domain2.com
RedirectMatch 301 ^/old-domain3.com/(.*)$ http://new-domain3.com/$1

Remember to update the .htaccess file on your server and test the redirects to ensure they are working correctly.