使用curl_getinfo返回200失败

I use this code to get info about webpages and files before download.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_NOBODY, 1); 

curl_exec($curl);

if (curl_getinfo($curl, CURLINFO_HTTP_CODE) == 200)
{ 
    echo $info['active'] = true;
    echo $info['url'] = $url;
    echo $info['size'] =     curl_getinfo($curl,CURLINFO_CONTENT_LENGTH_DOWNLOAD);
    echo $info['type'] = curl_getinfo($curl,CURLINFO_CONTENT_TYPE);

}
else
    echo 'not active';

It works for file or urls format like this:

www.example.com/film.mp4
www.example.com/film.php

but not works without extension name in URL..it return me 'not active';

www.example.com/film
www.example.com/film/test

how can I fixed it?

UPDATE:

it retun 403 error with CURLINFO_HTTP_CODE

This is not a problem with cURL; the website you are trying to pull data from is returning the 403 when you specify a URL without a file. Try loading those pages yourself in a browser to see.

403 Forbidden - The server understood the request, but is refusing to fulfill it.

If you are getting a 403 error with a HEAD request, and your URL is that of a directory (not a file name), then that means that the server refuses to expose the directory contents, and there isn't a default page (index.html, index.php, etc.) do display. This effectively means there is nothing to cURL at that location, and you can treat it as a 404 error (unless you need to do some extra authentication not described in your question).

Ref: HTTP status codes