This work describes a simple but novel analytical method for in situ monitoring of the diffusion process of drugs in hydrogels based on refractive index measurements. The diffusion process was monitored by recording the refraction of a laser beam passing through a triangular cell, which allows the determination of changes in the refractive index distribution from the deviated distance of the linear beam. Compared to conventional methods, this new method exhibits advantages such as more simplicity, lower cost, and speed. Further, the refractive index method permits the determination of the concentration distribution of solutes in the hydrogels at any time during the diffusion process under nondestructive circumstances. The precision was determined by successfully applying this new method to the diffusion of a typical antibiotic drug, cefazolin sodium, in agarose gels of various concentrations. By employing Fick's second law, the diffusion behavior was investigated and the diffusion coefficients of cefazolin sodium in agarose gels were therefore obtained. Amsden's physical model based on obstruction effect was applied to the simulation of the diffusion process of cefazolin sodium and turned out to fit the results quite well.