I think they are probably different, but I'm not sure. Opinions vary.
Rahab was alive at the time when Joshua fought at Jericho which would have been 2,553 years after Adam according to Bible data. Rachab was the wife of Salmon who was four generations before David who began to reign 3,063 years after Adam. Rahab the harlot would have been pretty old if she were the wife of Salmon.
Also, the NT mentions Rahab the harlot in Heb 11.31 and James 2.25, but Matthew 1.5 uses Rachab and omits the term harlot.
It was actually less than 440 years from Jericho to David. 1 Kings 6:1 says Solomon began building the Temple 480 years after the Exodus. This would be 440 years after Jericho fell. That was in Solomon's 4th year, and David reigned 40 years, starting at the age of 30. So the time from the fall of Jericho to the birth of David is 480 - (40 wandering + 4th year of Solomon + 40 of David's reign + 30 yrs old) = 366. (See https://hermeneutics.stackexchange.com/questions/29968/was-rahab-the-harlot-contemporary-with-salmonnear the bottom of blog by "child of God")
This following seems to make the years fit nicely using Bible dates.
from Greek Testament Commentary, Alford
"It has been imagined, on chronological grounds, that this Rachab must be a different person from Rahab of Jericho. But those very grounds completely tally with their identity. For Naashon (father of Salmon), prince of Judah (1Ch 2:10), offered his offering at the setting up of the tabernacle (Num 7:12) 39 years before the taking of Jericho. So that Salmon would be of mature age at or soon after that event; at which time Rahab was probably young, as her father and mother were living (Jos 6:23). Nor is it any objection that Achan, the fourth in descent from Judah by Zara, is contemporary with Salmon, the sixth of the other branch: since the generations in the line of Zara average 69 years, and those in the line of Phares 49, both within the limits of probability. The difficulty of the interval of 366 years between Rahab and David does not belong to this passage only, but equally to Rth 4:21, Rth 4:22; and is by no means insuperable, especially when the extreme old age of Jesse, implied in 1Sa 17:12, is considered."
"I may add that, considering Rahab's father and mother were alive, the house would hardly be called the house of Rahab except on account of the character commonly assigned to her."