Without knowing your setup its hard to say whats best to do since there is many ways to do a 301. However an easy way is to use htaccess ( if your server support this ) but most of them does.
More info how to do a 301 with htaccess can be found here