Rock salt and Epsom salt are two different chemicals. Though both are salts, chemically speaking, they cannot be used interchangeably.
In chemistry, a salt is a crystal made from ions (charged particles). The properties and uses of a salt depend on the elements it contains.
Rock salt is also known as the mineral halite, often used to melt ice. Chemically, it is sodium chloride, the same as plain table salt (NaCl), although rock salt has a coarser texture and is not pure enough for food.
Epsom salt is magnesium sulfate (MgSO4). It has a number of medical uses and can be taken internally as a laxative.
Superficially, rock salt and Epsom salt resemble each other. Both are coarse clear crystals that dissolve in water and both can be used as bath salts.
Rock salt should never be used for the same purposes as Epsom salt. They contain completely different elements and behave differently in the body. In fact, rock salt should not be used internally.