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/ima开发者_运维问答ges 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 www.example.com
Is this even possible?
This always works for me:
RewriteEngine On
RewriteCond %{HTTP_HOST} !.com$
RewriteRule .* http://www.example.com%{REQUEST_URI} [L,R=301]
or, if you prefer:
RewriteEngine On
RewriteCond %{HTTP_HOST} !.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
If still nothing — try adding QSA flag (but it should work fine as is):
RewriteRule ^(.*)$ http://www.example.com/$1 [QSA,L,R=301]
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论