Simple .htaccess to redirect all requests to another domain
Name this file .htaccess
and place it in the root directory of the domain you want to redirect from.
Replace my-new-domain.com
with the domain you want to redirect to. (remember in the RewriteCond
line, the .
in the domain needs to be escaped with a backslash!)
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-new-domain\.com$ [NC]
RewriteRule ^(.*)$ https://my-new-domain.com/$1 [L,R=301]
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow