First and foremost, we MUST understand that scratching is an innate behavior of cats. No amount of training nor punishment (Please...never punish your cat(s)!!) will stop cats from scratching. They may learn not to scratch in your presence, but they will still scratch. WHY do cats need to scratch? Cats scratch in order to maintain their nail health, which most people realize. But cats also scratch in order to receive an excellent stretch of their front legs, toes and shoulders; also to leave a physical and olfactory (scent) "calling card" of their presence in a territory. This is why we see even declawed kitties still maintain this behavior protocol (leaving an olfactory "calling card").
Because scratching is an action that is part of their natural behavior repertoire, it is a behavior that cannot be stopped. It is as essential as breathing. Some people believe punishment is the appropriate answer. However, punishing cats, and particularly for a natural behavior, NEVER works. Important to remember, scratching will continue when punishment is applied and is not because cats are now angry, "acting out" or resentful. As an innate behavior, they are driven to do it. At the least, cats will continue the behavior, but do it while the punisher is not around to "catch them in the act." At worst, punishment will be detrimental to the bond with your cat and create fear. Cats don't understand why you are punishing them and only see it as emotionally (and possibly physically) hurtful.
The above covers cats scratching on vertical surfaces. But what if kitty is scratching on a horizontal surface, such as the carpet at a doorway. One of the best ways to deter scratching there is to lay down carpet runner, nubby side up. Kitty will find it quite the irritant and definitely no longer an attractive surface. Placing a horizontal scratcher, such as those produced by Pioneer Pet and Imperial Cat (Product page) in those areas will give kitty a better option for scratching.
Consider why kitty is scratching in those areas. Is kitty secluded in a room and trying to get out? Making the room more comfortable and homey will help calm kitty down. Access to windows, vertical surfaces such as cat trees or even your own furniture is helpful. Also, keep the environment enriched. Using food puzzles, games and toys (see the enrichment tab) are great ways to keep kitty busy, stress free and happy.