A photonic crystal biosensor is a compact device fabricated from photonic crystal materials, which enables the detection and monitoring of the presence and concentration changes of biological molecules or chemical substances. In this paper, we propose a biosensor for cancer cell detection based on a silicon photonic crystal with a hexagonal resonant cavity introduced in a triangular lattice array. One of the bandgap ranges of this structure is 1188 nm≤λ≤1968 nm. When the incident light wavelength is within the range of 1188 nm≤λ≤1968 nm, the transmission coefficient of this structure at the resonant wavelength of 1469.58 nm is found to reach 99.62% through the finite difference time domain method, with a quality factor of 980. Subsequently, a biosensor is designed from this structure, with its sensing mechanism relying on the change in refractive index leading to a shift in the resonant wavelength. The target sample can be identified by observing the shift in the resonant wavelength. As cancer cells and normal cells possess different refractive indices, this biosensor can be used for their detection. The maximum sensitivity of the sensor is 915.75 nm/RIU and the minimum detection limit is 0.000236 RIU.