Jump to content

Detect Redirect using cUrl


marc.roberts

Recommended Posts

Is it possible to use cUrl to detect a redirect?

ie. cUrl opens http://www.here.com/ and is redirected to http://www.overthere.com/ upon this redirect, cUrl returns something... (doesn't matter what, the url that it was redirected to, the url that it was redirected from, a true etc.)

If this is possible, is it also possible to detect if the redirected page is secure or unsecure?

Thanks,
Marc
Link to comment
https://forums.phpfreaks.com/topic/30231-detect-redirect-using-curl/
Share on other sites

I believe there's an option within CURL called FOLLOWLOCATION which can be set to allow the object to be redirected.  You could try something with that.

You could grab the data of a url into a variable, with FOLLOWLOCATION off and then again with it on and then do a string compare.  If they're different, you know that a redirect has occurred.  This isn't ideal as dynamic content on the page could make it different each time you visit the page, giving the effect of a false positive.

Regards
Huggie

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.