Return HTTP Status Code

I guess if it is possible to obtain a HTTP response code (200 or 404) without fopening entire remote page. --> 200 THEN fopen() --> 404 THEN die()

I so would like to low overhead of server.


Return A Specific Http Status Code

Is there a way to have a php script return a specific http status code rather than relying on apache to do it?

View 2 Replies View Related

Get HTTP Status Code

I know how to retrieve text from elements like the title on a web page using PHP but how do I get the status code returned in the header and assign it to a variable?

View 4 Replies View Related

Using CURL Get HTTP Status Code Of A URL

I would like to get the HTTP status code of a URL using PHP. I think CURL is the way to go but I can't see how to do it. I see I can use curl_getinfo on the CURL session after I've curl_exec'ed it but I can't see what options I should set to get CURL to only get the HTTP status code and not retrieve the data at the URL.

View 2 Replies View Related

Parsing HTTP Status Code?

I am using PHP to parse the numeric portion of the HTTP status code response. Given a standard "HTTP/1.1 200 OK" response, I'd use:

$data = explode(' ', "HTTP/1.1 200 OK");
$code = $data[1];

I'm not an expert on HTTP. Would I ever encounter a response where the code is not at the position of $data[1] as in the above example? I just want to be sure that this method of delimiting the response code will always work for any response.

View 4 Replies View Related

Http Status Code 404 - Related To 404

So I'm using a single entry point found in a previous question of mine: [URL] We all know what 404 errors is, so no explanation needed there. However, when using the single entry point index.php?page=pokemon, it doesn't go to the 404 page when trying to access a page that is non-existent. So how can I solve this problem which would make it more user friendly and direct the visitors to my 404 page so they won't see all the PHP errors?

View 4 Replies View Related

Get The HTTP Status Code For A Remote Domain?

I would like to create a batch script, to go through 20,000 links in a DB, and weed out all the 404s and such. How would I get the HTTP status code for a remote url?

Preferably not using curl, since I dont have it installed.

View 5 Replies View Related

Http Status Code 500 - Set_time_limit Throws A 500 Error?

When I use set_time_limit and the script runs for any amount of time greater than 360 seconds, it throws a 500 error.359, nothing, 360 and above, error.I don't have access to php.ini, how can I fix this bug?

View 2 Replies View Related

Http Status Code Is Use To Tell The Client The Session Has Timed Out?

In a webpage, it uses YUI connection manager/datasource to send AJAX requests to the server, if the session (which contains the info on whether the user has been authenticated) has already timed out, those ajax responses that can only be viewed by authenticated users should return an http status code, telling the client that the session has already timed out, then the client either simply redirects him to the login page or asks him if he wants to extend the session.My question is that, in this situation, what http status code is the most appropriate to tell the client the session has timed out?

View 4 Replies View Related

Http Status Code 301 - 301 Redirect Error From Variable?

I am writing a 301 redirect, but getting an error when I pass the url through a variableI use this script to get the current page URL and Domain name.

$mainurl = "http://" .$_SERVER["SERVER_NAME"];
$pagename1 = "".$_SERVER["QUERY_STRING"];

If the page does not redirect I use this to redirect the page.

<?php if ($row_rs_page['g_page_url'] != $pagename1)
$pagenameexists = "<p>page exists</p>";

View 1 Replies View Related

Http Status Code 404 - Image Link In Function 404's

I have a valid link that goes to a picture located on my web server. It is a simple jpg image, I can copy and paste this link into my web browser and it loads fine. The issue comes in when I try to call a few php functions on the image. such as getimagesize or fopen. they both return 404 errors even though the image is there. Does anyone know that could be causing this?

View 3 Replies View Related

Http Status Code 404 Direct Access To Page?

Users to be able to access directly.

Code:function prevent_direct_access()


The URL does not change but the content does.Need to add to tell search engines that this is a 404 and not to index it.The URL to change though.

View 5 Replies View Related

Getting HTTP Status Code From Multiple URLs Using Curl_multi?

Alright, so I'm using curl_multi_* to connect to various sites simultaneously. How would I return the HTTP Status Code to a variable for comparison?

View 1 Replies View Related

CURL Always Return Status Code?

i have write code cURL with php but it's always return status code, '0' or '1' i want to get data json with my cURL i have set cURL opt 'CURLOPT_RETURNTRANSFER' to 1 but still get status code..

this my code

function fetch_page($url)
$ch = curl_init();
$array = array(


View 4 Replies View Related

Fetch The Contents Of A Page No Matter What HTTP Status Code?

I'm currently using file_get_contents() to fetch the contents of a page which is sort of like an Authentication API. It works great for the default system which most people use (which just uses the default HTTP/1.1 200 status code), but some people send relevant HTTP status codes for different errors. For example 401 PASSWORD_FAIL, in which case it would set the HTTP status to 401 and output 'PASSWORD_FAIL' to the page, which is the part I want to get. But the 401 status code causes file_get_contents() to error out and not do anything. What is the simplest PHP function I can use to get the contents of the page and just ignore the HTTP status code?

View 1 Replies View Related

Correct HTTP Status Code To Send When A Site Is Down For Maintenance?

Is there a HTTP status code to tell Google (and others) to go away, index me again later? Basically, one that semantically tells clients that the site is down for maintenance?

The ones I have considered are

304 => Not modified
307 => Temporary redirect
410 => Gone
503 => Service Unavailable

I'm leaning towards the last one, but was just curious as to which one was proper choice.

Is this the correct way to send it with PHP?

header('Status: 503 Service Unavailable');

View 4 Replies View Related

Return Specific Status Code (for Example 24) In Symfony

i need to return crazy http code statuses for API in symfony

i need to return status code 24 i try to do it with:


but i'm always getting response code 500

when i try to return "normal" status code like 404, 403:


View 3 Replies View Related

Turn Off Default HTTP Status Code Errors In Zend Server?

Every time I return some status code in my PHP code, Zend Server gives me following error appended on the bottom of my website (with the message of HTTP code I returned). So for example, if I return 401, it gives me another 401 error appended to my 401 page:

Is there any way to turn it off? I use Zend Server Community Edition 5.0 with PHP 5.2.


It seems to be default Apache error handling. Is there a way to disable it? Preferably without having my own error pages.


I tried to edit my .htaccess with ErrorDocument directives. It still gives me my error page (blank page) + Apache error (like on screenshot above).

This isn't happening with ZendServer 4 I have on server. I use ZendServer 5 on localhost tho. Is it possible to be some kind of bug or misconfiguration from Zend side?


(In all test cases I return 401)

When I use default ZendServer configuration + ErrorDocument directives in .htaccess, I get my own error page + Apache error page appended bellow it.

When I use default ZendServer configuration + disable my own ErrorDocument directives, I get just Apache error page.

When I change Apache error pages to blank files + use my own ErrorDocument directives, I get the desired behavior, however errors 404 still append default Apache errors bellow my own.

View 3 Replies View Related

Apache - Make Set HTTP Status Code To 500 Automatically In Case Of Any Error Condition?

I am running Apache 2.2.15 with PHP 5.3.2, 'display_errors' disabled, 'display_startup_errors' disabled, 'log_errors' enabled. At my setup (so I consider it a norm), PHP aborts on fatal errors, which is good, and sets HTTP status code to 500. Fatal errors include E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR and, probably, E_RECOVERABLE_ERROR (cannot trigger it myself, so can't easily check what happens). I think it is a good idea that it does set the code to 500, because I think it is the right thing to do - obviously if your script contains syntax errors and/or fails to do what is supposed to do at runtime, it is a server error, if we consider PHP part of the server.

Now, here is the important part: Anyway, I have now installed XDebug to track errors better, but I can see that now, no matter the error, even though the script aborts as before on fatal errors, the HTTP status code is always 200. This breaks my client that 'talks' to Apache/PHP via HTTP :|

Also, setting display_errors to On/1, makes PHP no longer set HTTP status code to 500 and exhibits exactly the same behavior as with XDebug above. I am very much dependent on reliable status code behavior here, and this all leads me to believe it's some kind of fluke or random like weather.. or am I missing something?[URL]..

For my part, I have disabled XDebug, seeing as it is what causes the bad behavior in the first place. I only used it for stack tracing anyway, and now use a custom error handler for that instead. Also, the linked article is from 2008, apparently PHP does set HTTP status code to 500 automatically these days. It does so here. Without XDebug, of course.

View 1 Replies View Related

On High System Load - Status Code Is Safe To Return?

I am wondering how can I issue a HTTP Status code, that will cause crawlers to try later for that content, as the system currently is running on high load. Does a 304 status and no content display resolves this issue?

View 3 Replies View Related

HTTP Return Code: 405

I'm trying to add a child node to my XML file with following PHP-script: PHP Code:

View 2 Replies View Related

Send A Status Code In PHP Without Maintaining An Array Of Status Names?

All I want to do, is send a 404 status code from PHP - but in a generic fashion. Both Router::statusCode(404) and Router::statusCode(403) should work, as well as any other valid HTTP status code
I do know, that you can specify a status code as third parameter to header. Sadly this only works if you specify a string. Thus calling header('', false, 404) does not work.Furthermore I know, that one can send a status code via a header call with a status line: header('HTTP/1.1 404 Not Found')But to do this I have to maintain an array of reason phrases (Not Found) for all status codes (404). I don't like the idea of this, as it somehow is a duplication of what PHP already does itself (for the third header parameter).So, my question is: Is there any simple and clean way to send a status code in PHP?

View 4 Replies View Related

Http Status Code 500 - Files On The Server Generated 500 "Internal Server Error"

Everything was working fine till last morning (12 hours ago). But now each of PHP page is showing "500 Internal Server Error". Please look at this link It's an WordPress site. I have thought it's about WordPress.

But I have a sub-domain, where there is a single PHP file -, which gets same error. Though at the same location, there is a HTML file, which works fine. To test if any syntax in PHP page causes that error, I have placed a "die('some message')" at the first line of that "index.php" file, but it shows same error. There is no HTAccess in that sub-domain.

Everything was working - suddenly all PHP stopped, I can't get the problem. Can anyone help?

*Latest Error log from cPanel*

[Mon Jun 27 14:42:30 2011] [error] [client] File does not exist: /home/abusadat/public_html/demo.abusadat/404.shtml
[Mon Jun 27 14:42:30 2011] [error] [client] File does not exist: /home/abusadat/public_html/demo.abusadat/favicon.ico
[Mon Jun 27 14:42:29 2011] [error] [client] File does not exist: /home/abusadat/public_html/demo.abusadat/404.shtml
[Mon Jun 27 14:42:29 2011] [error] [client] File does not exist: /home/abusadat/public_html/demo.abusadat/favicon.ico
[Mon Jun 27 14:42:26 2011] [error] [client] File does not exist: /home/abusadat/public_html/demo.abusadat/404.shtml

View 1 Replies View Related

Fopen Failed "HTTP Request Failed", But Response Header Has A Status Code 200?

I have a PHP script, that should connect to a proxy, chosen from a proxy list and download a file. Some of the proxies (out of 200-400 working ones) work perfectly, but others don't, and I cannot find out why.Here the code that connects through the proxy:

$proxy = determine_proxy ($proxyList);
$proxyString = 'tcp://' . $proxy['ip'] . ':' . $proxy['port'];
$userAgent = $userAgents [rand (0, $agentsCount - 1)];


View 2 Replies View Related

HTTP Status For Functional Redirect?

Right now we've got web pages that show UI elements, and web pages that just process form submissions, and then redirect back to the UI pages. They do this using PHP's header() function:

header("Location: /other_page.php");

This causes a 302 Found response to be sent; according to the HTTP 1.1 spec, 302 is for cases where "The requested resource resides temporarily under a different URI." [HTTP 1.1 spec]

Functionally, this is fine, but it doens't seem like this is the proper status code for what we're doing. It looks like 303 ("See Other") is the appropriate status here, so I'm wondering if there's any reason not to use it. We'd have to be more explicit in our use of header(), since we'd have to specify that status line rather than just a Location: field.

View 3 Replies View Related

Use Self Defined Http Status Codes?

so http status codes are

1xx, 2xx, 3xx, 4xx, 5xx.

Could we self define http status codes such as 9xx for our own usage?

I didn't see too many people use self defined http status codes. I prefer not to use self defined http status codes. But I have no authentic reasons against it.

Here is one which use self defined http status codes.


The advantage for that is we only need to check the header response and no need to check the body.

View 3 Replies View Related

Getting HTTP Status Codes For Web Pages Through Proxy

I'm having a terrible time trying to get HTTP status codes from web pages (404, 200, 301, etc.). I think a big part of the problem is that we're behind a proxy.

How would I modify the following code examples to connect through a proxy in order to get the status code?

function http_file_status($url, $followRedirects = true)
$url_parsed = parse_url($url);
if (!@$url_parsed['scheme']) $url_parsed = parse_url('http://'.$url);
if(!@$port) $port = 80;
if(!@$path) $path = '/'
if(@$query) $path .= '?'.$query;
$out = "HEAD $path HTTP/1.1";
$out .= "Host: $host";
$out .= "Connection: Close";
if(!$fp = @fsockopen($host, $port, $es, $en, 5)){
return false;
fwrite($fp, $out);
while (!feof($fp)) {
$s = fgets($fp, 128);
if(($followRedirects) && (preg_match('/^Location:/i', $s) != false)){
return http_file_status(trim(preg_replace("/Location:/i", "", $s)));
if(preg_match('@HTTP[/]1[.][01x][s]{1,}([1-5][01][0-9])[s].*$@', $s, $matches))
$status = $matches[1];
return $status;
return false;


header("Content-Type: text/plain");
$host = "";
$port = 80;

$post = "HEAD / HTTP/1.1";
$post .= "Host:";
$post .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20060308 Firefox/";
$post .= "Keep-Alive: 200";
$post .= "Connection: keep-alive";
$sock = fsockopen($host, $port, $errno, $errstr, 20.0);
fwrite($sock, $post, strlen($post));

while (!feof($sock)){
echo fgets($sock);

View 1 Replies View Related

Remotely Checking HTTP Status With CURL?

I am trying to generate rows based on the code below. Would someone be able to tell me what I am doing wrong? I can't get the error reporting to work where I am. Are you able to use cURL within while loops?

while ($row = mysql_fetch_array($result_entries))
if ($row['active'] == "y") {
$ch = curl_init($row['url']);


View 2 Replies View Related

Update Facebook Status By Http Request?

I try to send http request like: "POST [URL] but I receive nothing... in twitter I success: "POST [URL]"' I must use it in this way ,because of GFW...

View 1 Replies View Related

Parsing HTTP Status Codes For Interacting With API?

I'm building a script in PHP to interact with an API and need to be able to parse the HTTP status code the API is giving me. For the most part, it gives one of the following responses:

HTTP/1.1 401 Unauthorized
HTTP/1.1 403 Forbidden
HTTP/1.1 404 Not Found
HTTP/1.1 410 Gone

I need to be able to recognize which response is being given, and, if its 401 or 410, to keep going, but, if it's 401 or 403, to keep track and to shut down the script after a few in a row (because I've exceeded my call limit for the day). My code is pretty simple:

for($i = $start;$i < $end;$i++)
// construct the API url
$url = $base_url.$i.$end_url;


My problem is I don't know what to put in the 'else' loop. I'm using the CodeIgniter framework, if anyone knows of any shortcuts to use. Also, I'm open to using cURL, but never have before.

View 2 Replies View Related

Reading Header HTTP Status Information From URL's

I have a MySQL Database which has a URL field.It has roughly 5000 records.
My Goal is to read all the URL's and print their HTTP Status Code (Like if its 200 OK or 404 etc)Information to the Screen. Now i did this using the CURL below CURL FUNCTIONS. Code:

View 3 Replies View Related

Copyrights 2005-15, All rights reserved