Let's support you have the following rules in your .htaccess file.
#1
Redirect /old-page.php http://newsite.com/target-page.php
or if you want a 301 (permanent) redirect
#2
Redirect 301 /old-page.php http://newsite.com/target-page.php
The redirects above work just fine but they are not optimal. Why?
They do not append the query parameters to the target link.
This is important in case you or somebody is doing SEO work on your site.
He/she have appended Google Analytic's parameters to the landing page(s).
For example if I want to lead people to my site I'll create a link like this.
http://orbisius.com/?utm_source=/howto/how-to-properly-redirect-from-one-page-or-site-to-another-using-htaccess-mod_rewrite-rules&utm_medium=club.orbisius.com&utm_campaign=article
The link includes parameters which I you will be able to use to identify the sources of my traffic.
Example:
Here's how to do a better redirect by appending the query parameters.
# Custom rules in .htaccess
RedirectMatch 301 ^/?(.*) http://newsite.com/$1
RedirectMatch 301 ^/products/product1/?(.*) http://newsite.com/products/product1/$1
Note: If you are using a Content Management System (CMS) such as WordPress, Drupal, Joomla the examples here can be done using modules/components/plugins.
The .htaccess solution uses fewer server resources because it happens BEFORE the CMS has loaded its libraries and modules.
If you want just want to redirect non-www to www site use these rules.
RewriteEngine On #RewriteBase / RewriteCond %{HTTP_HOST} ^yoursite\.com # redirect only GET requests RewriteCond %{REQUEST_METHOD} GET # uncheck this if you want to redirect requests made to a specific file #RewriteCond %{REQUEST_URI} /wp-login.php RewriteRule (.*) http://www.yoursite.com/$1 [L,R=302]