In Star Wars: The Force Awakens, there is a very powerful weapon used by the First Order to destroy the Hosnian system. Their next target is the planet D'Qar. How did the First Order know the base of the Resistance was located on this planet?
The Rebels sent a recon ship to go and have a look at the Starkiller Base. Unbeknownst to the ship's crew, they were tracked back to the Ileenium System.
Note that the First Order don't actually know which of the (numerous) planets and moons in the system are host to the Rebel base. Luckily Snoke has a solution for that, blow up the local star.
Though visibly angry, Snoke’s tone remained unchanged. “Have we located the main Resistance base?”
Hux was clearly gratified to be the bearer of good news. “We were able to track their reconnaissance ship back to the Ileenium system. We are coordinating with our own reconnaissance craft in the area in order to lock down the specific location of their base.”
Snoke replied with cold satisfaction. “We do not need it. Prepare the weapon. Destroy their system.”
This scene also appears in the film's screenplay, albeit with slightly different wording
Snoke is visibly furious.
SNOKE: Then the Resistance must be destroyed before they get to Skywalker.
GENERAL HUX: We have their location. We tracked their reconnaissance ship to the Ileenium system.
SNOKE: Good. Then we will crush them once and for all. Prepare the weapon.
It's said right out in the film, 1 hour 29 minutes in.
01:29:17,356 --> 01:29:19,451 Then the Resistance must be destroyed
01:29:19,567 --> 01:29:21,299 before they get to Skywalker.
01:29:21,410 --> 01:29:22,957 We have their location.
01:29:23,721 --> 01:29:26,274 We tracked their reconnaissance ship to the Illenium system.
01:29:27,006 --> 01:29:28,006 Good.
01:29:28,640 --> 01:29:31,339 Then we will crush them once and for all.
01:29:31,409 --> 01:29:32,857 Prepare the weapon.
This Reconnaissance ship was sent by the Resistance after Finn gives them info on the Starkiller Base Superweapon. A few minutes earlier, 1h22m:
01:22:26,428 --> 01:22:28,700 Finn's familiar with the weapon that destroyed the Hosnian System.
01:22:28,811 --> 01:22:29,861 He worked on the base.
01:22:29,939 --> 01:22:32,171 We're desperate for anything you can tell us.
01:22:32,282 --> 01:22:34,694 That's where my friend was taken. I've got to get there fast.
01:22:34,848 --> 01:22:38,748 And I will do everything I can to help, but first you need to tell us all you know.
A few touching Han/Leia moments:
01:25:08,300 --> 01:25:12,564 General, the reconnaissance report on the enemy base is coming.
Then some more Han/Leia, until we get to the planning scene:
01:32:00,976 --> 01:32:04,424 The scan data from Snap's reconnaissance flight confirms Finn's report.
So after Hosnian Prime's destruction, Finn tells the Resistance about Starkiller Base and the Resistance sends Temmin "Snap" Wexley to check it out. The First Order finds this reconnaissance ship and traces it back, targeting the Illenium system.
Logically, the First Order doesn't know know that it's the Resistance Headquarters, but they would know there is some Resistance presence there. And since the Starkiller super weapon can target Multiple planets at the same time, they can use their overwhelmingly superior power to destroy everything at the same time. There is no kill like over-kill. The Starkiller weapon targets all the planets, not just D'Qar.