user3586017
user3586017

Reputation: 11

HTTP request 301 and 302 error

I am using the http_request()(http://pear.php.net/package/HTTP_Request2/) to check the page status. Its working fine but in the time of checking the external links it returns 301 and 302 error.but those links are loading perfectly in browser.

For example: the link http://siris-implant.ch is loading perfectly in browser but in the time checking with http_request() it returns 302 error status.

please suggest us, how to resolve this issue.

Upvotes: 1

Views: 738

Answers (2)

AbraCadaver
AbraCadaver

Reputation: 78994

All 300 responses are redirects.

Since release 0.5.0 HTTP_Request2 can automatically follow HTTP redirects if follow_redirects parameter is set to TRUE:

HTTP_Request2($url, METHOD_GET, array('follow_redirects'=>true))

Or use setConfig().

Upvotes: 0

Quentin
Quentin

Reputation: 943635

If I visit http://siris-implant.ch/ in my browser, it redirects me to http://siris-implant.ch/de/.

So it doesn't load, it tells me to go somewhere else to find what I am looking for.

That is what 302 means. It is not an error. (Errors are in the 400 and 500 ranges of status codes).

You need to follow the redirect (by looking at the HTTP location response header) and see if the URL it resolves to is in an error state or not.

Upvotes: 2

Related Questions