How to get good recommendations in online courses?
In order for me to want to write a student a good letter of recommendation, I typically want to see two things: 


mastery of the material (at least enough to earn an A- or better in the course)
engagement with the material 


Most often (2) comes through asking me good questions in office hours, although in one case that I recall, I was really impressed with the student's final paper.  Although she already had the top grade in the course, she went above and beyond on the final paper.  I wrote her a glowing letter of rec, and she ended up winning at least one scholarship.

Now to answer your question, I suggest that you approach a web-based course similarly.  Obviously, work hard to do well in the course.  But also make an effort to get to know the instructor a bit.  Many web-based courses have some type of office hours (perhaps a scheduled chat-room time).  Whatever format you have available, take advantage of it (possibly this could be only a forum; not ideal, but still workable).  Take time to think of good questions about the material, and ask them in office hours.  If you have the chance, let the instructor get to know you a bit, too.  It's much easier for your instructor to write a letter of rec for you if they know you well enough to have something to say.