I recall my English teachers (30-40 years ago) reminding us that this is an issue of vicinity and affinity.
Additionally, in synthetic languages, the order of words in a phrase is mostly commutative.
English is said to be an analytic language, rather than being a synthetic language, but does retain some synthetic features. IMO, we should differentiate between portmanteau-istic synthesis of words versus actual grammatical "syntheticalism" of sentences (morpheme synthesis vs grammatical relation synthesis).
Synthetic construction is made possible by the existence of morpheme inflection. Having retained a large repertoire of inflected grammar, synthetic relationship is sometimes still possible in English. For example, at the risk of succumbing to Yoda grammar, all the following are equally valid but not equally unusual structures.
- She kissed him.
- She him kissed.
- Kissed him she.
- Kissed she him.
- Him she kissed.
- Him kissed she.
However, the most comprehensive structure in English is direct active [Perpetrator-Action-Target] speech : She kissed him.
The only rule you need to use is the rule of best comprehension. Comprehension is affected by the effects of prominence, affinity and vicinity.
- only costs $1.
- costs only $1.
- costs $1 only.
In the above example, if you wish to emphasize being merely $1, when you would place only as near as possible to $1 and in a prominent position - costs only $1.
There may be times when you would be in the mood of emphasizing that costing $1 is the only consideration you have in mind, and you would choose to say only costs $1.
There may be times when you would be in the mood to hide being only from being prominent, when you would say costs $1 only. I believe this sentence structure violates traditional etiquette of clarity in English, and therefore, traditionalists would frown at its use. Though, I do notice its being used frequently in parts of Asia.