Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Script for Broken Links

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
Watch

freeflow

Established Member
Impact
13
Does anyone know of a simple PHP script with which I can check if links in a TS are broken?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Try this,

PHP:
foreach($urls as $url)
{
    $headers = get_headers($url, true);
    if (!preg_match('/ok/i', $headers[0]))
    {
        print $url . ' ' $header[0];
    }
}
 
1
•••
I added the code below, but it still doesn't work.
$url = 'http://test.com';

What else do I have to add test the script?

Try this,

PHP:
foreach($urls as $url)
{
    $headers = get_headers($url, true);
    if (!preg_match('/ok/i', $headers[0]))
    {
        print $url . ' ' $header[0];
    }
}
 
0
•••
Here is a tested version:

PHP:
/* $urls is an array of the websites you want to check */
$urls = array('http://example.com/', 'http://acmedomains.com/', 'http://this-domain-dosent-exisit.info');

/* loop through each url in $urls */
foreach($urls as $url)
{
    /* just get the http headers, not the whole page to save time */
    !$headers = get_headers($url, true);


    /* Check if response header is 'OK', other wise print the error message */
    if (!is_array($headers) || !preg_match('/ok/i', $headers[0]))
    {
        print "{$url}\n";
    }

}
 
0
•••
Thanks for your help. :)
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back