0

I want to eliminate from my database urls that do not work. Many of them have working redirects. These are OK and should not be eliminated. To check 404 is not a problem. I have tested more than 100 solutions (curl, get_headers etc.) but I have not found one that gives a positive result, for example for this address http://www.alwro.com.pl. As you can check, the browser will display the content of the page https://alwro.com.pl/. But I haven't found any php code that can detect this url exists (OK, url does not exist but website exists and that is the point). Maybe someone has a PHP script that will detect the existence of this particular url ("http://www.alwro.com.pl"). This url is just found example (good for testing) and I expect much more like this one. That's why I am asking for help

Martin
  • 22,212
  • 11
  • 70
  • 132
Mark
  • 1
  • use cURL to check the response code from the URL [Reference](https://stackoverflow.com/questions/11797680/getting-http-code-in-php-using-curl) – Martin Oct 20 '20 at 17:40
  • 6
    Could you show us one of your "100 solutions", and what result it gives for that URL? (Click [edit] and add some code, in the form of a [mcve]). Because it seems to be a straight-forward 301 redirect, so presumably you've just defined "available" too narrowly, e.g. checking specifically for status 200. – IMSoP Oct 20 '20 at 17:42
  • Does this answer your question? [Getting HTTP code in PHP using curl](https://stackoverflow.com/questions/11797680/getting-http-code-in-php-using-curl) – Martin Oct 20 '20 at 17:42
  • I would do it in javascript, if you want to I can show a solution with Javascript – Marcello Perri Oct 20 '20 at 18:56
  • Martin. The problem is that from given example url you will no get any response - no headres. – Mark Oct 20 '20 at 19:11
  • Thank you very much Marcello Perri. But I have to run it in php to ask database and update it after getting result by result. I do not know Javascript at all :( – Mark Oct 20 '20 at 19:20
  • To all my Friends. As I responded to Martin, The problem is that from given example url you will no get any response - no headres (maybe redirect in javascript or something else). The easiest way is to assume that the url is dad. But it is not. – Mark Oct 20 '20 at 19:26

1 Answers1

0

I did it by checking dns, assuming that site exist when there is dns answer. It is very fast and easy. $dns = dns_get_record($domain, DNS_NS);

Mark
  • 1