A static method that returns true if the URI supplied is "internal" to the current Joomla installation; otherwise it returns false.


boolean isInternal( $uri )


Argument Data type Description Default
$uri string URI to be tested against the Joomla installation URI.


In this example, the Joomla site URI is shown and a number of sample URIs tested against it.

echo 'Joomla URI is ' . JURI::base() . "\n";
$array = array( 'http://localhost/joomla/index.php',
foreach ($array as $key => $uri) {
    echo ($key+1) . ': ' . $uri . ' is ';
    echo JURI::isInternal( $uri ) ? 'internal' : 'external';
    echo "\n";

would output

Joomla URI is http://localhost/joomla/
1: http://localhost/joomla/index.php is internal
2: http://localhost/anotherjoomla/index.php is external
3: http://localhost/joomla:8080/index.php is external
4: http://localhost/joomla:80/index.php is external
5: is external
6: http://localhost/joomla/administrator/index.php is internal
7: http://localhost/joomla/administrator/index.php?task=view&id=32#anchorthis is internal
8: https://localhost/joomla/index.php is external

Noting that:

  1. Is internal because the base URIs are identical.
  2. Is external because the path to the Joomla installation is different.
  3. Is external because the port numbers differ.
  4. Is external because the port numbers differ, even though port 80 is the default port for the HTTP protocol.
  5. Is external because the host names differ, even though resolves to 'localhost'.
  6. Is internal even though the paths differ.
  7. Is internal even though the paths, queries and fragments differ.
  8. Is external because the schemes differ.

See also