.htaccess Redirect Subdomain to External URL

I tried both options but didn't work until I remove the $ and [L,R] this is the code that worked for me

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
 RewriteRule ^(.*) http://newdomain.com.ar/?param=data&uparam2=data

hope it helps.


If you are redirecting a subdomain to another domain then there shouldn't be anything else in the .htaccess file other than this.

 # This will redirect a subdomain to another domain
 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^yoursubdomain\.yourdomain\.com$ [NC]
 RewriteRule ^(.*) http://www.newdomain.com/$1 [L,R]

Here's the code I used and it worked for me:

# BEGIN CUSTOM Redirects
# This will redirect a subdomain to another domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^pw\.example\.com$ [NC]
RewriteRule ^(.*) https://www.example.com [L,R