Why are flight recorders generally located in the tail?
When an aircraft is crashed, the entire front of the aircraft is expected to act as a crush zone. By placing FDRs and CVRs near the tail, the shock wave that reaches FDRs and CVRs is reduced significantly.

The probability of survival based on seating is shown in this picture:


(Image Source)

Hence one can see that the shock wave reduces as it reaches the rear of the plane. That is the reason FDRs and CVRs are installed in aircraft's empennage section.


(Image Source)



Please note that the precise location of the recorders depends on the individual plane. Sometimes they are located in the ceiling of the galley, in the aft cargo hold or in the tail cone that covers the rear of the aircraft.