I have 2 domains .com and .net.
I would like to redirect the .net to .com domain with the full URL, so just the domain changes. For examples:
If a user visits:
http://www.example.net/images/myImage.png he gets redirected (using 301 redirect) to http://www.example.com/images/myImage.png.
http://www.example.net/images goes to http://www.example.com/images
http://www.example.net/index.php?att=1&att=2 goes to http://www.example.com/index.php?att=1&att=2
I tried this:
RewriteEngine on
RewriteCond %{HTTP_HOST} !.com$
RewriteRule /(.*) http://www.example.com/%{REQUEST_URI}$1 [L,R=301]
But if the query string (?att=1&att2=3…) isn’t set it goes directly to http://www.example.com
Is this even possible?
This always works for me:
or, if you prefer:
If still nothing — try adding
QSAflag (but it should work fine as is):