The voltage divider is good in theory but you are missing the point that the voltage dropped is proportional to the current drawn. The top (24V end) resistor is carrying the current used by the AMS1117 internal circuits and the load after it, the bottom resistor isn't. If you measure the voltage at the junction of the two resistors (input to regulator) you will see it is much lower than 12V and probably too low for the regulator to function properly. Also bear in mind that you lose 1V more at the input for each 0.1mA load you place on the regulator.
If your load current isn't too high, you could try adding a 12V zener diode in series with the regulator input pin, otherwise your only option is a pre-regulator to give a steady low voltage before it reaches the AMS1117.
Brian.