I'm trying to echo out a url in my classic ASP (JavaScript) pages. I have a little function to append a query string to the URL and echo it. My problem is that my string is being modified before being output; the protocol is changed to match the current protocol (http / https) and the subdomain is also changed (www or nothing). I don't want this to happen.
Here's my function that I'm using to append the query string:
function writeUrl(langcode, url)
{
if(url.indexOf('?')==-1)
{
url = url + '?lang=' + langcode;
}
else
{
url = url + '&lang=' + langcode;
}
Response.Write(url);
}
Pretty simple, no? This function is included in the top of the page in question like this:
<!-- #include virtual="/inc_url.asp" -->
Lastly, in the page itself, I call the function. The 'lang' attribute is a 2-letter string.
<% writeUrl(lang, 'http://www.example.com/somepage'); %>
On visiting http://example.com/somepage?lang=fr I would have expected the above code to echo this:
http://www.example.com/somepage?lang=fr
However, I get any of the four following values, each one matching up with the URL I'm visiting:
Http://example.com/somepage?lang=fr
https://example.com/somepage?lang=fr
http://www.example.com/somepage?lang=fr
https://www.example.com/somepage?lang=fr
Can anyone point out somehing I'm missing? I'd like the URL to be output without that kind of modification: I want to use it for rel=canonical.
And no, re-writing it in .net is not a possibility.
New information - Even the URL when hard-coded into the html, even in a comment is changed. So, if I put <!-- http ://www.example.com/ -->
into the html, then when I access it from https://example.com, it has been re-written as <!-- https ://example.com -->
. This seem to confirm it's something down-stream. Any more ideas? (spaces added above so I don't exceed max number of hyperlinks).