Nails, or a similar fixing of your choice. That is about the only thing that will stop it moving in the direction of the nap of the carpet. Alternatively, cut back the carpet and insert a door mat well.
A few months ago I asked a similar question - and had a number of useful responses. Went to a local independent carpet shop for something else, saw some heavy anti-move material, bought some.
Worked for both mother (who has a lovely rug which kept moving over the fitted carpet) and the off-cuts are doing a great job for us. Not certain how well it would work under a rubber-backed mat, but it might be fine. I was deeply sceptical but, other than wondering how long it will last, do now believe it works.
The problem, however, lies in telling you what it is! It is around a metre wide, looks like most other non-woven material. Colour is a mixture of white and black in what looks like it should be a pattern but you can never identify any regularity - maybe it is random? It is thicker than other such products I have seen. Feels very sticky to touch. Appears to be exactly the same as John Lewis sell in pre-cut pieces - but was a bit less expensive.
Remove carpet for a metre or two around the door. Tile the exposed floor, leaving an un-tiled rectangle that you fill with a quire mat that you cut to size. This gives a fixed mat and an easy-clean area to walk on before reaching the carpet.
I was thinking of some mechanical device which the mat sits on and which in turn sits on the carpet and is also secured to the door frame along one side with some removable fasteners or something like that.
HomeOwnersHub website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.