Dendritic spines are the primary postsynaptic sites of excitatory neurotransmission in the brain. They exhibit a remarkable morphological variety, ranging from thin protrusions, to stubby shapes, to bulbous mushroom shapes. The remodeling of spines is thought to regulate the strength of the synaptic connection, which depends vitally on the number and the spatial distribution of AMPA-type glutamate receptors (AMPARs). We present numerical and analytical analyses demonstrating that this shape strongly affects AMPAR diffusion. We report a pronounced suppression of the receptor exit rate out of spines with decreasing neck radius. Thus, mushroomlike spines become highly effective at retaining receptors in the spine head. Moreover, we show that the postsynaptic density further enhances receptor trapping, particularly in mushroomlike spines local exocytosis in the spine head, in contrast to release at the base, provides rapid and specific regulatory control of AMPAR concentration at synapses.