The following general advice appears on several sites:-
turn the contents of your compost bin regularly (at least twice per year). This not only disturbs any rats that have taken up residence but also aerates your compost heap which speeds up the process of digestion and reduces the amount of methane (a greenhouse gas) your heap emits.
Plastic compost bins should be given a small gauge wire mesh liningat the base or can be placed on paving slabs to prevent rats from burrowing in from underneath. regularly kick your compost bin to ensure it is not a peaceful place for rats to sleep.
no household waste! Never put meat, dairy, bones, cooked foods or other inappropriate items in your compost bin. This will attract rats and make your bin smell.
harvest ripe fruit and vegetables promptly and take them home to enjoy (before somebody else eats them!).
do not leave discarded fruit and vegetables on the ground; clear them away to your compost bin, as these are a source of food for rats and other pests.
keep your plot tidy and ensure that allotment gardens do not become overgrown or allow rubbish to build up e.g. timber, old carpet, stockpiled materials etc, as this provides cover for rats to live under.