Redirect to new domain htaccess

The classic redirect to a new domain using .htaccess!

Here's the syntax:

Redirect 301 / http://newdomain.com/

This will redirect all requests from the old domain to the new domain, preserving the URL path.

If you want to redirect a specific directory or subdomain, you can specify it:

Redirect 301 /oldsubdomain http://newdomain.com/newsubdomain/

Or, if you want to redirect a specific URL:

Redirect 301 /oldpage.html http://newdomain.com/newpage.html

The 301 status code is a permanent redirect, which is recommended for most cases. If you want to use a temporary redirect, use 302 instead:

Redirect 302 / http://newdomain.com/

Make sure to update the http:// or https:// protocol to match the protocol of your new domain.

Also, if you're using a subdomain, you might need to add a RewriteCond directive to exclude the subdomain from the redirect:

RewriteCond %{HTTP_HOST}!^www\.newdomain\.com [NC]
Redirect 301 / http://newdomain.com/

This will redirect all requests from the old domain to the new domain, except for requests to www.newdomain.com.

Remember to update your .htaccess file and restart your web server for the changes to take effect.

Hope this helps!