Take them out a lot. Adjust their feeding schedule and wait 20-30 minutes depending on the age of the dog. Then take them outside and let them do their thing. Wait until they have used the bathroom before you bring them back in. If this takes some time, bring them back in, wait 2-5 minutes and then take them back out.
The idea is to show the dog that going outside is a good thing. Do not hit, scold, rub their nose in it, simply say NO when you catch them, take them outside and be done with it. If you don’t catch them, clean up the mess and go on with your life.