Try this in the page your load:
$prefix = $_SERVER['HTTP_HOST'];
$file = explode('/', $_SERVER['PHP_SELF']);
$page = $file[count($file)-1];
if (file_exists($prefix.'/it/'.$page)) {
http_redirect($prefix.'/it/'.$page); // For Italian
}
if (file_exists($prefix.'/de/'.$page)) {
http_redirect($prefix.'/de/'.$page); // For German
}
if (file_exists($prefix.'/fr/'.$page)) {
http_redirect($prefix.'/fr/'.$page); // For French
}
In JavaScript (jQuery click example) you would do something like this:
var host = document.location.hostname;
var path = window.location.href;
var filename = path.replace(/^.*[\\\/]/, '');
$('.myItalianLink').click(function(){
window.location.href = host + '/it/' + filename; // For Italian
});
console.log(host + '/it/' + filename);
Outputs:
http://www.mywebsite.com/it/html4.php
The JavaScript approach will likely be more suiting for your needs, as it's more reactive in case of user interaction (the links you named).