I would like to create a redirect if the user is not logged in and clicks a course/lesson

I would like to create a redirect if the user is not logged in and clicks a course/lesson, can you help?