HttpStatus() Working Incorrectly?

I've recently noticed that HttpStatus() is not working as it used to. The statuses of active URLs return 200 as expected, but the issue appears when testing against redirected URLs and / or broken pages (see #1 & #2 below). I've tried the following:

  • Applying all 5 request methods as the 3rd parameter
  • Turning cache on and off from GlobalSettings
  • Increasing / randomizing delays between requests
  • Running from different computers (one on a public network and one on a company VPN)
  • Reviewing previous posts such as HttpStatus on Amazon, etc

I've been using SeoTools v9.7.0.4 since March 22, but I wasn't paying close attention to know if that's when this started.

—————————————————————————

#1. Redircted Pages — When testing URLs with known redirects, it appears that HttpStatus() is only returning the status of the final URL, not the status of the URL in the argument.

For example, the following URL is definitely a redirect (a chain, in fact), but HttpStatus() is reporting it as a 200:
=HttpStatus( "https://www.penfed.org/personal" ) = 200 OK (should be 301)

Related functions, UnShortUrl(), RedirectList() and RedirectCount(), are all working correctly and report the expected results. Unfortunately, none of these provide the important status codes that I'm needing.

—————————————————————————

#2: Broken Pages — When testing URLs that are known 404's, HttpStatus() is returning an Excel error, rather than 404 Not Found.

For example, the following URLs do not exist, but instead of returning 404 Not Found, all result in #VALUE! errors:
=HttpStatus( "https://www.penfed.org/bogus-url" ) = #VALUE! (should be 404)
=HttpStatus( "https://www.amazon.com/bogus-url" ) = #VALUE! (should be 404)
=HttpStatus( "https://www.ebay.com/bogus-url" ) = #VALUE! (should be 404)

—————————————————————————

For reference, here are my current settings:

I stopped using httpstatus because it too often reported a 200 OK for redirects. Instead I now use redirectcount to identify redirects in one cell and unshorturl in another to identify the final landing page.

Hey, @RichTatum. Thanks for chiming in on this!

I've used your approach when auditing redirect chains. Unfortunately, I'm needing the initial status code to differentiate between redirect types (i.e. temporary, permanent, JS, etc).

Hopefully, the guys can get this fixed soon.

1 Like

For anyone needing an immediate solution to getting a URL's HTTP Status, I've written the following UDF called HttpRequest(), and I'm providing it to this community free to use (aka Unsupported).

Simply copy the code below into a VBA module, then create a reference (Tools > References) to: Microsoft WinHTTP Services, version 5.1.

Usage: =HttpRequest( "https://ebay.com" )
Result: 301 Moved Permanently: https://www.ebay.com/


Public Function HttpRequest(ByVal url As String) As String
'
' by Tim Wolfe, https://www.linkedin.com/in/WolfeDen/
'

Dim httpObj As Object
Dim location As String

    On Error Resume Next
    Set httpObj = CreateObject("WinHttp.WinHttpRequest.5.1")

    With httpObj
        .Option(6) = False
        .Open "GET", url, False
        .send
        location = .getResponseHeader("Location")
        HttpRequest = .Status & " " & .statusText _
            & IIf(location <> "", ": " & location, "")
    End With

    On Error GoTo 0
    Set httpObj = Nothing

End Function

Hi @WolfeDen, thanks for reporting. I will be reviewing the various http redirect/status issues in the next week or so!

1 Like