Shaftesbury is a town and civil parish in Dorset, England. It is on the A30 road, 20 miles west of Salisbury and 23 miles north-northeast of Dorchester, near the border with Wiltshire.