Rabbits like peeing on soft things, and it’s likely he just really likes peeing on the rug, so I suggest physically relocating him to the litterboxes, in addition to putting soiled bedding in them.
In terms of him peeing when he’s being pet, it’s a difficult territory, but I advise, while on the carpet, watch his bottom like a hawk if you’re petting him— you don’t want him mistaken it as confirmation that peeing is fine there. If you’re getting ready for a petting session with him, you can take him to the litterbox so he can relieve himself if he needs to, then proceed to pet. I do this with Wick occasionally when it’s been a while since he’s gone and he’s getting sleepy… he tends to just pee where he is once he wakes up from a nap, so I need to make him take a potty break beforehand.
The answers provided in this discussion are for general guideline purposes only. The information is not intended to diagnose or treat your pet. Seek the advice of your veterinarian or a qualified behaviorist.