[TUTORIAL] How to Quickly Index Your Links using IndexNow (Custom PHP Script by Laurentiu - beautiful-romania.com).

Feel free to start a conversation on any subject, whether it's related to Romania or not. This is our place for open talk about anything and everything.
Post Reply
User avatar
Laurentiu
Site Admin
Posts: 393
Joined: Wed Jan 14, 2026 2:18 pm
Location: Cuib, Prahova, Romania
Contact:

[TUTORIAL] How to Quickly Index Your Links using IndexNow (Custom PHP Script by Laurentiu - beautiful-romania.com)

Post by Laurentiu »

If you want your new posts or updates to appear almost instantly in search engines like Bing or Yandex, you should use IndexNow. This protocol allows you to "push" your URLs directly to search engines instead of waiting for them to crawl your site.

To help our community, I’ve prepared a simple PHP script that handles this process for you.

Step 1: Get your API Key from Bing Webmaster Tools
Before using the script, you need to prove you own your website:

1. Log in to your Bing Webmaster Tools account.
2. Navigate to the IndexNow section.
3. Click on Generate API Key.
4. Download the API key as a .txt file (e.g., 8b76bc87e7ec4a3695b275f202555.txt) and upload it to the root directory of your website.

Step 2: The IndexNow PHP Script
Create a new file on your server (e.g., indexnow.php) and paste the following code created by me. Make sure to update the host, key, keyLocation, and urlList with your own details.
  • Important: Every link in the list must be followed by a comma (,), except for the very last link in the list.
If you add a comma after the last link, or forget one between links, the script will return a "Syntax Error" and won't be able to send your data to IndexNow.

Code: Select all

<?php
$data = [
    "host" => "YOURWEBSITE.COM", // Change to your domain
    "key" => "YOUR_GENERATED_BING_KEY", // Your Bing API Key
    "keyLocation" => "https://YOURWEBSITE.COM/YOUR_KEY_FILE.txt", // Link to the txt file
    "urlList" => [
        // Add the links you want to index here
        "https://beautiful-romania.com/viewtopic.php?t=13",
        "https://beautiful-romania.com/viewtopic.php?t=17",
        "https://beautiful-romania.com/viewtopic.php?t=19"
    ]
];

$ch = curl_init('https://api.indexnow.org/indexnow');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json; charset=utf-8']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "Status HTTP: " . $httpCode; 
if ($httpCode == 200) {
    echo " - Success! ALL " . count($data['urlList']) . " links have been sent.";
} else {
    echo " - Error. Status code: " . $httpCode;
}
?>
Step 3: Run the Script
Once you have added your new links to the `$urlList` array (Up to 10.000 links), simply access the file in your browser:
https://yourwebsite.com/indexnow.php

Friendly Tip: If you have a Sitemap, just copy the links from there and paste them between quotes in the script to save time and avoid typos!
The Quotes: Every single link must be enclosed in double quotes " " exacly like in the example from the code ;).

If you see **Status HTTP: 200**, it means the search engines have successfully received your links and will prioritize them for indexing!
  • **Note:** Remember to update the `$urlList` every time you have new content you want to index quickly.
One Submission, Multiple Search Engines
The beauty of this script is that you only need to run it once. IndexNow is a shared protocol, which means:
  • Bing & Yandex: Once you submit your links to the IndexNow API, they are automatically shared between these major search engines.
  • Automatic Synchronization: Other search engines that adopt the IndexNow standard will also receive your updates instantly from this single request.
There is no need to create separate scripts for each search engine. One click does it all!

Step 4: Verification (What Success Looks Like)
After running the PHP script, you should see a "Status HTTP: 200" message. To confirm that search engines have processed your links, you can log back into Bing Webmaster Tools.
Go to the IndexNow section, and you will see a list of your submitted links. It will look like this:

Image

If you need more help with that, reply here and I will help you.
If you like this article, please share it. ↗️
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 0 guests