With the popularization of mobile devices with positioning functions, location-based service (LBS) plays a vital role in people's daily lives. The problem of privacy leakage becomes more and more critical. Although the application technology of LBS is developing rapidly, the corresponding privacy protection technology is growing slowly. At present, differential privacy technology has received attention from many researchers, but it is not easy to reasonably apply it to trajectory privacy protection. Most trajectory privacy protection models only focus on the spatial location of mobile users without considering the temporal characteristics of the trajectory, which destroys the spatial–temporal characteristics of the trajectory. Therefore, to beat this difficult problem, a differential privacy trajectory data protection scheme based on R-tree is suggested. Firstly, the trajectory similarity tree structure is proposed on the basis of R-tree index structure to realize the trajectory data's spatial storage and query processing. Secondly, the DPTS-tree (Differential Privacy Trajectory Similarity tree, DPTS-tree) is constructed with differential privacy technology, adding noise to the statistical values of mobile users in the nodes, which can greatly improve the ability to resist arbitrary background knowledge attacks and achieve the purpose of protecting data privacy. Then, to resist other information inference attacks in the trajectory data, when constructing the DPTS-tree, random noise is added to location data and other data in the trajectory. Finally, the algorithm is subjected to consistency constraints to address the problem that the added independent noise may cause data inconsistency. Experiments show that our algorithm can effectively protect sensitive and private information of users and ensure the usability of trajectory data.