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. It is the only significant hilltop settlement in Dorset, being built about 215 metres above sea level on a greensand hill on the edge of Cranborne Chase.