The simplest way would be to do a long division to compute the remainder, toggle the target bit if there is a non-zero remainder, then uncompute the long division.
Here is an example $r=3$, $N < 16$ circuit in Quirk:
Note the displays on the right hand side, which show that conditioning on the output qubit (the bottom one) leaves only values divisible by 3 in the input register (the top 4 qubits).
The basic idea is to keep track of the maximum value $m$ that could possibly be in the input register $i$, then iteratively pick the largest $k$ such that $r^k \leq m$ and subtract $r^k$ out of $i$ if $i \geq r^k$. This reduces $m$ by $r^k$. Repeat this until $m < r$, then toggle your output bit if $i=0$. Then uncompute all the conditional subtractions to restore $i$.
A proper construction would not require $r$ subtractions for each value of $k$ as this one does, and a proper construction would expand the comparison and addition circuits into their full form, but I think this construction gets the right idea across.