Gabriella said:
Hi,
I understand that all three URLs are possible, but I want to know
WHICH ONE is being used by the webserver.
If you look at
http://www.rsizr.com you will see they redirect you to
http://rsizr.com - that's what I'd like to know!
That's what
http://validator.w3.org/checklink gives you.
Server.XMLhttpRequest only tells you, according to the status number,
whether this URL is broken or valid. Not good enough.
I need to know which exact URL is being used.
I'm not sure what Server.XMLhttpRequest is but I'll assume we are actually
talking about MSXML2.ServerXMLHTTP.3.0.
The site you give as an example is responding with a 301 Moved Permanetly
status and carries the header Location:
http://rsizr.com.
ServerXMLHTTP will internally follow this redirection and will return
normally with a 200 response. The problem is that there is no way to
determine the final URL used internally to complete the request with MSXML3.
MSXML6 does provide an option to discover this.
The best and most compatible way is to use the underlying WinHTTP component
which on Win2000 SP2 or higher is present without additional installs:-
Function FinalURL(rsURL)
Dim oWinHTTP
Const WinHttpRequestOption_URL = 1
Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
oWinHTTP.Open "HEAD", rsURL, False
oWinHTTP.Send
FinalURL = oWinHttp.Option(WinHttpRequestOption_URL)
End Function
sFinalURL = FinalURL("
http://www.rsizr.com/")
You should note however that some sites still rely on HTML meta tags to
proform a similar function. In those cases this technique isn't going to
help.