Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add counter of 30x redirects. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

randytate
Copy link

I wanted to be able to tell if a URL was redirected due to OpenGraph/Canonical tags ... or if it truly was a redirect.

    $url = $row["Destination URL"];

    // Not Found, until we determine otherwise
    $row["URL Status"] = "Not Found";
    $url_result = $resolver->resolveURL($url);

    if ( $url_result->didConnectionFail() ) {
        $row["URL Status"] = "Connection Failure";
    }
    else if ( $url_result->didErrorOccur() ) {
        $row["URL Status"] = "Error Occured";
    }
    else if ( $url_result->getHTTPStatusCode() == "404" ) {
        $row["URL Status"] = "Not Found";
    }
    else if ( $url_result->isStartingURL() ) {
        $row["URL Status"] = "OK";
    }
    else if ( $url_result->redirect30xCount() ) {
        $row["URL Status"] = "Redirect (" . $url_result->redirect30xCount() . " times)";
        $row["Redirect URL"] = $url_result->getURL();
    }
    else {
        $row["URL Status"] = "Not Canonical";
        $row["Canonical URL"] = $url_result->getURL();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant