It’s depending from software that are you used. I work with 3dsmax.
1) In 3dsmax this solved by using matte/shadow material, it’s depend from situation.
2) Or you may set you rendering as Render by Elements (in 3dsmax) and in selection menu you should select Shadow channel and some other channel’s for compose you scene in (photoshop or another software).
3) For older versions of 3dsmax, was created small plug-in that called Chameleon.
But if you using Maya, I think there is some method like this one. I mean, you should find Render by Elements menu.