Clearly, the indexes must be a power of the same prime!

However, I believe that that is all that is needed.

Let and be the subgroups of finite index, of index and respectively. Let .

Then, if then and . So, clearly divides . So, let where does not divide . As and are both of prime power index then and . Thus, as required.

EDIT: There is a much neater way. One can use the second and third isomorphism theorems!

If then by the second isomorphism theorem. This means that is of index for some (why?).

By the third isomorphism theorem, . Everything is of finite index, so as required.