Extension talk:HideReferringPage
Add topicFails to follow external links
[edit]No installation problems on MW 1.14.0, however after enabling this extension all external links now direct to the page 'Extensions/HideReferringPage/redir.php' (and not the specified external url). Are the Configuration parameters fully outlining the required setup steps? --Mega 19:34, 9 March 2010 (UTC)
Issues
[edit]I had to hack it to get it to redirect at all (and then it doesn't hide the referrer). Replace the modifyExternalLinks in HideReferringPage.php with the following:
function modifyExternalLinks(&$url, &$text, &$html) {
$path = $_SERVER['SCRIPT_NAME']; # hack and might not work in all situations
$path = $path . "/extensions/HideReferringPage";
$html = '<a href="'.$path.'/redir.php?url='.urlencode($url).'" class="external text" rel="nofollow" title="'.$url.'">'.$text.'</a>';
$html = str_replace('index.php/', "", $html);
return false;
}
To hide the referrer, I am using one of the many many dereferer sites. Replace the contents of redir.php with the following:
<?php
$url = $_GET["url"];
# Search for dereferer and choose your favourite:
$dereferer = "Enter URL to dereferer here";
header( "Location: {$dereferer}{$url}" );
?>
Ddaltun 17:19, 3 June 2011 (UTC)
Issues with short URLs
[edit]I experienced issues when using short URLs. These problems can be fixed by a solution similar to one outlined above:
function modifyExternalLinks(&$url, &$text, &$html) {
global $wgScriptPath;
$html = '<a href="'.$wgScriptPath.'/extensions/HideReferringPage/redir.php?url='.urlencode($url).'" class="external text" rel="nofollow" title="'.$url.'">'.$text. '</a>';
return false;
}
The same change applies to the other function:
function modifyExternalImages(&$url, &$alt, &$img) {
global $wgScriptPath;
$img = '<img src="'.$wgScriptPath.'/extensions/HideReferringPage/redir.php?url='.urlencode($url).'" alt="'.$alt.'"/>';
return false;
}
I believe that my solution might be a bit more robust as it employs the configuration variable from the settings. --92.77.110.141 12:13, 28 June 2011 (UTC)
Limit to http and https
[edit]Is there any reason not to have this extension ignore all URLs unless they start with http or https? We have hacked our local version to do just that after fighting its attempt to run when using mailto and other URLs.