I had the same problem. I think it has to do with the length/novelty. When I read online I'm reading MANY different things. I do read a couple hundred pages of books each day now though.
The quality of the book matters, preferably with occasional illustrations. I've been buying a large amount of Folio Society books. I love them. I like the feel of the hardcover, the thickness of the pages, the illustrations and just how amazing they look on a book shelf. It all helps me to enjoy reading for longer.
Find Ambience that is themed for the book you're reading. I'm rereading A Song of Ice and Fire. I like using https://youtu.be/_N-IREy7C9s. It gets and keeps me in the mood. I'll use other Game of Thrones themes as well on occasion but that Winterfell one is my favorite for GoT. I need other things going on while I'm reading, noise that enhances the experience is perfect for that.
Break it up. Some books I really love but can't stick to. I tend to have about 3-4 books In reading at a time. I read just one chapter at a time. I might switch books, I might take a break, I might read one book for 5 hours straight. But the goal/intention is just to read one chapter. At the end of the chapter, I decide if I want to keep reading, keep reading this book or switch books, or do something else.
I like having books with differing time requirements. Lengthy ones for days off. Short stories/chapters for breaks. Some books like GoT, Farseer, LOTR, King killer, are great to absorb for hours at a time. Others, like Sherlock Holmes, are great for me to read in small sections.