⊗ppPsPtFS 41 of 84 menu

Links to External Sites in PHP

In real life, a website can have a mix of absolute paths, relative paths, and paths to external sites. We need to be able to filter out links leading to external sites.

Let targ.loc be the site that we are parsing. Get an array of href leading to this site, perform their normalization, excluding links to external sites:

<a href="page.html">text</a> <a href="./page.html">text</a> <a href="../page.html">text</a> <a href="http://targ.loc/page.html">text</a> <a href="https://targ.loc/page.html">text</a> <a href="http://othr.com/dir/page.html">text</a> <a href="https://othr.com/dir/page.html">text</a>
frendekkhy