1

I am trying to build a front end application which will an input text box.

When a user enters an URL in the text field(ex www.google.com, wwww.facebook.com, www.linked.com, etc..), the web app should tell the user whether if the provided address has a re-direction?

Can it be done from ajax?

Rajendra kumar Vankadari
  • 2,247
  • 1
  • 16
  • 16

1 Answers1

0

You can send a GET request to the URL and see what it returns.

Every HTTP response will come with a status code.

You can see the full list of HTTP status codes here: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

A 301 means the URL has a permanent redirect and a 302 means there is a temporary redirect.

Tom
  • 2,543
  • 3
  • 21
  • 42