In previous studies, ranging errors in the line of sight (LOS) environment were often overlooked, resulting in an increase in positioning errors. In non-line of sight (NLOS) conditions, the measuring distance hardly participates in the location calculation, leading to the loss of useful positioning information. Thus, this paper proposes a WiFi RTT positioning approach based on LOS compensation and trusted NLOS recognition, which improves the performance of RTT positioning by using the compensated LOS distances and trusted NLOS ranges to estimate location. In the proposed approach, NLOS and LOS identification need to be implemented first. A support vector machine algorithm is used to construct a real-time model that recognizes NLOS and LOS distances based on the proposed classification features. Then, the distances under NLOS and LOS environments are evaluated and compensated, respectively, to obtain reliable NLOS ranges and calibrated LOS measurements. A least squares algorithm is utilized to build the LOS distance compensation model, and Bayesian theorem is applied to recognize the trusted NLOS ranges. The compensated LOS distances and credible NLOS ranges are used for estimating the location. The experimental results demonstrate that the proposed algorithm achieves excellent positioning accuracy, with a mean absolute error of 1.082 m. This signifies a substantial enhancement of 53.34% when compared to the least squares algorithm, a remarkable 60.24% improvement over the weighted centroid positioning algorithm, a significant 36.11% progress in comparison to the RTNLIA algorithm, and a noteworthy 32.82% boost relative to the NLRNB approach.