I have an script that grabs content from third party sites and if the url is not found the site redirects with a 302 header location to a custom not found webpage instead of sending a 404 not found. The script also caches the content returned by curl_exec but i don't want to cache the error pages, so is there a way to log those redirects if i have turned on CURLOPT_FOLLOWLOCATION? How can i solve this situation? I know i could just find the error message using a dom parser and if found just discard it, but i want to know if there is other ways to accomplish this.
I ended up disabling followlocation so i just have to catch the 302 code and if it's present i don't cache the page. Thought there would be a way of catching all codes before curl redirects.
Have a look at Easy way to test a URL for 404 in PHP?
Then using that, just do not cache the page if there is a 404
See here:
http://www.php.net/manual/en/function.curl-getinfo.php
This provides such data. This feature is built into this class:
http://semlabs.co.uk/journal/object-oriented-curl-class-with-multi-threading