301 redirect sub-domain to main domain

I'm trying to 301 redirect an entire sub-domain to a page on my main website. I can't seem to get the code to work.