I have tried this but it's not working
function hideRedLinks (LinkRenderer $linkRenderer, LinkTarget $target, &$text, &$extraAttribs, &$query, &$ret) {
if ( $target->exists() ) {
return true; }
else {
$ret = $html;
return false;
}
}
$wgHooks['HtmlPageLinkRendererBegin '][] = 'hideRedLinks';