but then we have to worry about http[s]/port #/etc. $ext = strpos( $_SERVER['SCRIPT_NAME'], 'index.php5' ) === false ? 'php' : 'php5'; $path = ''; if( isset( $_SERVER['SCRIPT_NAME'] )) { $path = htmlspecialchars( preg_replace('/index.php5?/', '', $_SERVER['SCRIPT_NAME']) ); } ?>