'htaccess: redirect all requests to different domain (without query arguments)

How can I redirect all requests (irrespective of what page is being requested) on sub.domain.com to newdomain.com? Currently I have

Redirect 301 / http://www.newdomain.com/

When a requests comes in for domain.com/shop/product the redirect goes to newdomain.com/shop/product while it should just go to newdomain.com



Solution 1:[1]

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

That will forward any GET requests.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Xaerxess