
Originally Posted by
LuiePL
How can I change the links for a given domain from http to https? For example:
http://www.domain.com would become http
s://www.domain.com
Presumably you don't control the rendering of the document but you can insert a script into it?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Change Link Protocol</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<a href='http://mydomain.com'>LINK</a>
<a href='http://mydomain.com/nuts/r/us?b=2'>LINK</a>
<script type="text/javascript">
(function http2https( theDomain )
{
var dl = document.links, len = dl.length, re = new RegExp( "^http:(\/\/" + theDomain +".*)" );
for( var i = 0; i < len; i++ )
dl[ i ].href = dl[ i ].href.replace( re, "https:$1");
})( "mydomain.com" );
</script>
</body>
</html>
Bookmarks