JURI/isInternal
From Joomla! Documentation
A static method that returns true if the URI supplied is "internal" to the current Joomla installation; otherwise it returns false.
Syntax
boolean isInternal( $uri )
where:
| Argument | Data type | Description | Default |
|---|---|---|---|
| $uri | string | URI to be tested against the Joomla installation URI. |
Example
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', 'http://localhost/anotherjoomla/index.php', 'http://localhost/joomla:8080/index.php', 'http://localhost/joomla:80/index.php', 'http://127.0.0.1/joomla/index.php', 'http://localhost/joomla/administrator/index.php', 'http://localhost/joomla/administrator/index.php?task=view&id=32#anchorthis', 'https://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: http://127.0.0.1/joomla/index.php 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:
- Is internal because the base URIs are identical.
- Is external because the path to the Joomla installation is different.
- Is external because the port numbers differ.
- Is external because the port numbers differ, even though port 80 is the default port for the HTTP protocol.
- Is external because the host names differ, even though 127.0.0.1 resolves to 'localhost'.
- Is internal even though the paths differ.
- Is internal even though the paths, queries and fragments differ.
- Is external because the schemes differ.