How to relieve stiff neck pains?

Let me help you. Perform range-of-motion and strengthening exercises while pain symptoms are present, move on to low-stress exercises (e.g. Walking, swimming or cycling) after pain symptoms have improved (typically two to four weeks), avoid heavy lifting, strenuous exercise and uncomfortable positions , use medication as directed maintain normal activity , consult your doctor . Good luck. Thank you.
Use cervical pillow. Buying a cervical pillow at a medical supply store is a good place to start. If expence is an issue, you can roll up a large bath towel and adjust the thickness to support your neck in a position that is anatomical and does not bend your neck to either side. For men, avoid extending your neck while you shave. If this doesn't improve your pain, you can purchase a cervical traction devise.
Additionally-DO Eval. Gentle range-of-motion exercises & general conditioning exercises have been previously mentioned; all good ideas. Many times, however, the pain may be coming from another source - even the low back or the upper ribs, shoulder problems, etc., but manifest as 'stiff neck.' anr osteopathic hands-on diagnostic evaluation might prove helpful at finding the cause & could give immediate, lasting relief.
First find cause. Need to first hopefully determine the source/cause of your neck pain- past trauma/injuries, posture, even a TMJ/TMD issue. See a Dr. and get evaluated.
See below. Mild: heat/ice, rest, gentle stretching and ibuprofen/naproxyn/acetaminophen trial. If any outstanding medical history: trauma, chronic meds, age >50yr, numbness/tingling/weakness or persistent/severe pain, weight loss, fever or unresponsive pain relief in spite of rest-see your doctor for a thorough history and physical exam.