Recently I needed to change the end of one of our domains from .com to .org. However we wanted to maintain any old links that pointed at the .com domain.

Using mod_rewrite you can achieve this move seamlessly for users, and keep all the parameters in tact. Simply add the following lines to your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example.com$
RewriteRule (.*) http://www.example.org/$1 [R=Permanent]

All requests for www.example.com will be rewritten to www.example.org. It’s that easy!