How to check whether the URLs is redirecting or not

Hi,

Im trying to check the status of URL, whether the URL has redirecting or broken link. I’ve tried with HTTPs activity its give me the status of URL not the response. Example if i open “google.com” its redirecting to “Google”. I want to get the status as 301 or 302 and the redirected link. By using HTTPS activity its give me status as 200. Any other option?

Any suggestion.

redirect.xaml (6.7 KB)

Thanks @vvaidya,

Its working fine, but if i pass a broken link its throwing an exception.

“Message: The remote server returned an error: (404) Not Found.” If Status is 404 how to save this value to a variable.

Surround the code by Try Catch and in the catch block:

1)use “System.Net.Webexception” and assign ex.Status.ToString to your Variable

2)also use “System.Exception” for other errors.

I don’t think order matters.

Thanks,

Vinay

Hi,
Can you please provide us an example.

Fyi…

redirect_exception.xaml (12.9 KB)

@vvaidya, Hey, i have tried using this code for a link on which redirect is applied but it is throwing 401 error. Do you know why?

To check whether a URL is redirecting or not, you can follow these main points:

  1. Use an online url redirect checker. There are various online tools available that can check whether a URL is redirecting or not. You can simply enter the URL into the tool, and it will tell you whether it is redirecting or not.
  2. Check the HTTP status code: If you have access to a command-line interface, you can use the curl or wget command to check the HTTP status code of the URL. If the status code is 3xx, it means the URL is redirecting.
  3. Use a web browser: You can simply enter the URL into your web browser and see if it redirects to another URL. If it does, then the URL is redirecting.
  4. Use a network tool: You can use a network tool like Wireshark or Fiddler to monitor the network traffic and see if the URL is redirecting.
  5. Check the URL structure: You can also check the URL structure to see if it contains any redirects. If the URL contains a redirect parameter, such as “?redirect=” or “&url=”, then it is likely that the URL is redirecting.

Overall, there are various methods available to check whether a URL is redirecting or not, depending on your level of technical expertise and the tools available to you.

There are numerous ways to detect URL redirection.

On Browser:

Inspect Element > Network> Refresh the page or trigger the action that you believe initiates the redirect. Look for the network requests in the list.The redirect should appear as one of the requests, and you can check its response status and the “Location” header to see the redirect target.

On Windows command-line PowerShell:

Use the curl or wget command followed by the URL you want to test.

Exam: curl -I https://example.com`

Look for the HTTP response status code and the “Location” header in the output. If the response code is in the 3xx range (e.g., 301, 302), it indicates a redirect, and the “Location” header will contain the redirect target.

Online redirect checker application tools:

There is lots of redirect check tool I Personally recommend RedirectChecker.com You can get detail redirection chain along with http status code in detailed information.

Linux or macOS terminal:

curl -I -L example.com

These command-line tools allow you to fetch the headers of a URL and examine the redirection information. They provide the HTTP response status code and the “Location” header, allowing you to identify any redirects and determine the target URL.