PHP script for testing links on a web page

Link Checker scans all pages in your site and detects broken links and redirects.

The broken links tester is an indispensable tool for servicing the site, in relation to users and search engines. It is necessary to remove all broken links, as well as update redirects, whether external or internal to the site, for the correct image of the site and for better positioning.

This program is an alternative to the Xenu program, has the advantage of grouping results by tested pages, which makes editing easier, and it is portable.
Compared to the online validator, the W3C has the advantage of not being blocked on some pages.

In addition, this open source program is easy to edit using Script or PHP source code. It works with PHP 5 on almost all operating systems and computer models.

A Link Checker version with graphical UI is also available. It is more difficult to install, but easier to use .

Orders and Usage

The command line script can be executed by the Script PHP compiler:

solp linche [options] page

or directly by the PHP 5 interpreter:

php linche.php [options] page

The page is the full URL of the shape:

https://www.example.com/index.php

Parameters:

-r recursif, suivre les liens internes. Par défaut  seule la page est testée.
-s liste courte (short) affiche seulement les liens brisés et les liens sur des pages redirigées, sur le site.
-f accéléré (fast), en réduisant l'attente du serveur. Par défaut 5 secondes, on peut définir le délai
   en ajoutant une valeur après -f.
-v verbeux, affiche tous les liens testé, avec le code d'en-tête trouvé. 
Par défaut affiche seulement les erreurs.
-q quiet, silencieux, n'affiche rien.

The program produces a file called links.log, which contains all the results and will be saved under a different name if you want to save.

The results provided by the script are perfect. Sometimes the message "broken" appears when the page is available in the browser. This is because the response time or from the server is too long. In this case, it is enough to ignore the result.

Error messages and actions

When a script attempts to access a page, the server may return different code depending on the state of the page. It can be redirected either through a .htaccess file or through a PHP script, it may be absent.

Note that most often the program displays a message instead of an HTTP code:

These different codes, other than the OK code, will not be counted until the page is available, except for persistent redirects that need to be updated.

For a complete list of codes and their meaning, see the HTTP Code document.

With the -s option, only the codes are considered:

Versions

Obtaining a program and license

This review channel is licensed under the GNU GPL 2.0. You can use it free of charge and freely. If you distribute the archive, you must keep the copyright at the top of the Script and PHP source code.
Possible changes and improvements to the code should be provided in the form of open source Script and PHP, even if you are using a modified online program.
If PHP is not installed, you must load the interpreter in version 5 on the php.net.

  1. Download zip file,
  2. unpack it,
  3. open a command prompt window and
  4. execute the program in the window using the above command.

Free script under the GNU GPL 2.0 license

See also...

To cancel
For a static node only, check for broken links and redirects. In the second case, he replaces the URL with his new address.