Hello
I have a website in php in which I have some kind of portal to external
links that come from a database. When a user clicks on a link,
"link.php" is called, does some stuff (e.g. adds 1 to the visit-count
of that certain page) and then forwards the user with a location-header
to the asked page. Now my question: is it possible to get the
response-code of that asked page? E.g. when code 404 is returned, I
can put that in the database and then it's easy for me to know when a
link is broken.
Kind regards,
Bart 4 2401
Bart schreef op de grote markt:
I have a website in php in which I have some kind of portal to external
links that come from a database. When a user clicks on a link,
"link.php" is called, does some stuff (e.g. adds 1 to the visit-count
of that certain page) and then forwards the user with a location-header
to the asked page. Now my question: is it possible to get the
response-code of that asked page? E.g. when code 404 is returned, I
can put that in the database and then it's easy for me to know when a
link is broken.
No. When you send a location header to the client, the client requests
the page it is redirected to. Your PHP page only points to the new
page, but is not involved in the retrieval of it. Therefore, it can not
retrieve the headers or the page itself, and thus not the return code
which is part of the headers.
..oO(Bart op de grote markt)
>I have a website in php in which I have some kind of portal to external links that come from a database. When a user clicks on a link, "link.php" is called, does some stuff (e.g. adds 1 to the visit-count of that certain page) and then forwards the user with a location-header to the asked page. Now my question: is it possible to get the response-code of that asked page? E.g. when code 404 is returned, I can put that in the database and then it's easy for me to know when a link is broken.
No, because it's the browser that request the other page, not your
script.
But you could let your script perform such a check from time to time:
Maybe every 10th click on that link (or if the last check was more than
1 month ago) your script itself could send a request to the other site
to check its state. If the check succeeds, store the result in your DB
and send the redirect to the browser.
Micha
Michael Fesser schreef:
But you could let your script perform such a check from time to time:
Maybe every 10th click on that link (or if the last check was more than
1 month ago) your script itself could send a request to the other site
to check its state. If the check succeeds, store the result in your DB
and send the redirect to the browser.
Micha
Ok, thx, I'm already a lot wiser and maybe this is what I'm going to
do. It's a nice suggestion.
Bart
"Bart op de grote markt" <ba********@fre egates.bewrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Hello
I have a website in php in which I have some kind of portal to external
links that come from a database. When a user clicks on a link,
"link.php" is called, does some stuff (e.g. adds 1 to the visit-count
of that certain page) and then forwards the user with a location-header
to the asked page. Now my question: is it possible to get the
response-code of that asked page? E.g. when code 404 is returned, I
can put that in the database and then it's easy for me to know when a
link is broken.
Kind regards,
Bart
Yes.
When link.php "does some stuff" have it send a HEAD request to the link
url.
If it comes back as "200 Ok" forward the user to the page, if it comes back
as "404 Not Found" or any other error response show the user an error page
on your site and log the error for that link.
If the response comes back with a 3** redirect, you could parse that url
and check it (possibly set up a loop to check multiple redirects), forward
the user, or just show an error if you don't want the links to redirect
your users.
Rich This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Foord |
last post by:
#!/usr/bin/python -u
# 15-09-04
# v1.0.0
# auth_example.py
# A simple script manually demonstrating basic authentication.
# Copyright Michael Foord
# Free to use, modify and relicense.
# No warranty express or implied for the accuracy, fitness to purpose
|
by: Richard Eibrand |
last post by:
Hi guys,
How do I go about getting the http response status as with the httplib
method <connection_handle>.getresponse() using urllib2?
Thing is I need to authenticate with a server, which I can do with urllib2
(by passing credentials), but I also need to get the status response codes
and not only when raised as an exception.
Any ideas? I've gone google blind at this stage - as I'm not able to find
|
by: Colin Crossman |
last post by:
So, I'm trying to write a web spider for some data gathering from a
public database webserver. Anyway, in response to a POST, the webserver
returns "200 Script Results Follow" instead of "201 CREATED". While
both IE and Firefox ignore the odd header, this response kills my
HttpWebRequest with a WebException - "System.Net.WebException: The
server committed a protocol violation. Section=ResponseStatusLine".
Does anyone know of a...
|
by: Kals |
last post by:
Hi
I have problem to port my old ASP page to ASP.Net
the ASP file codes goes below
<
Dim ob
Dim xmldo
Dim strRs
Set xmldoc = Server.CreateObject("Microsoft.FreeThreadedXMLDOM"
|
by: Alvin A. Delagon |
last post by:
Greetings!
Is there any way I can obtain the HTTP status codes when using the
urllib module? As of now I can only think of doing a regex on the
result of the read(). Thanks in advance! ^_^
| |
by: Anbu |
last post by:
I already posted this message on usenet groups. But no response. I'm trying
with the Microsoft community now, hoping to get some resolution.
I have an Intermediate Web service developed using .NET and WSE 3.0 between
a Java service and .NET Client. The client works, similar to Digest
authentication (which first sends data without credentials, but later on will
send data with credentials based on the output - HTTP response code). The...
|
by: whisher |
last post by:
Hi.
Sorry to disturb you but I can't
figure out its use in this snippet
(Found in many scripts about Ajax)
function loadpage(page_request, containerid)
{
if (page_request.readyState == 4 && (page_request.status==200 ||
window.location.href.indexOf("http")==-1))
{
document.getElementById(containerid).innerHTML=page_request.responseText;
|
by: Reporter |
last post by:
Here is an example from the PHP Manual
<?php
if ((!isset($_SERVER)) || (1==1)) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
|
by: rajeeshun |
last post by:
Dear all,
This is my first post in this forum.
I am writing a small module for my company that send XML data to a gateway (Asp page) and get the response in XML format
I have to send the data (request) in XML format to a web site and need to get the response for the request
First I tried with Webclient (System.Net.WebClient) with following codes
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |