Matthew Woods, 19, from Chorley, Lancashire, admitted sending a grossly offensive public electronic communication He was given the maximum sentence, less a third for his early guilty plea.
Among the comments Woods posted on Facebook were: 'I woke up this morning in the back of a transit van with two beautiful little girls, I found April in a hopeless place' and, 'Who in their right mind would abduct a ginger kid?'
He also wrote, in reference to missing Madeleine McCann, 'Could have just started the greatest Facebook argument ever. April Fools, Who Wants Maddie?'
He was arrested for his own safety after a 'vigilante mob' of 50 went to his home after seeing the messages, which also included sexually explicit comments about missing five-year-old April.
April disappeared a week ago from near her home in Machynlleth, Wales. Mark Bridger, 46, is charged with her abduction and murder.
Matthew Woods. Pic: PA
Martina Jay, prosecuting, said: "When interviewed by police he fully admitted he posted messages about the two missing children. He said he did it in a bid to make people think his account had been hacked. He said it got out of hand."
David Edwards, for Woods, said: "He did seem genuinely remorseful and regretful for what he had done. At the time he posted these comments not once did he think he would find himself where he is today.
"He fully accepts he was the author of his own misfortune."
Sentencing, chairman of the bench Bill Hudson said: "This was a disgusting and despicable crime which the bench find completely abhorrent.
"There were words used and references made to the case in Wales and Madeline McCann who went missing in Portugal some years ago were nothing less than shocking. So much so no right thinking person in society should have communicated to them such distress.
"The families of those children should not be subjected to any use of social media like this. We should all be aware of the sensitivity of other people and especially the family involved in such statements made on Twitter, Facebook and such like. We felt there was no other sentence which would convey the abhorrence that many people have for this sort of crime."
There were cheers in the courtroom as Woods was sentenced.
More:Advice And Health
Suggested For You
Get top stories and blog posts emailed to me each day. Newsletters may offer personalized content or advertisements. Learn more