

Why or when do we need a redirect? Like we have seen before if a document is not found our web server should respond with a 404 status code. We will not look at the server configuration in more detail because this is about PHP and Zend but here is the link to the mod_rewrite documentation for Apache 2.2. htaccess file as a redirect or a rewrite. For an Apache web server this is usually within the.
#Zend redirector plus#
There are other types of error plus we can add real redirect options into the web server. Like before a web page is returned as well. Internal Server Error: If the web server has to send the request to a script engine like PHP (CGI) and does not get back a proper response (or in time) it will return a 500 error. Together with the response a web page is returned, which is either the default page specified with the server for this type of error or a specially designed page and configured into the server. Page not found: If the server cannot locate the requested path or document its response is 404.
#Zend redirector code#
You could send any page with an error code and a user would not know. A user agent simply displays the HTML document page submitted by the server along with the status code. These are status code 404 and 500 which are not redirects but nevertheless do not return the expected web page.Īlthough we sometimes see the code in the browser, a user agent itself should and does not care about it. Watch out: The status codes are part of the HTTP specification not HTML! Other server responsesīefore we dive into redirects lets look at two other common types of response by a web server. If there are problems or special situations like our redirects the response has a different number. The response contains a status code which is 200 OK if everything is normal. When we redirect we send a response telling the requester to send a different request! That is the whole secret of redirecting in a nutshell, but we are not there yet. Keep these two things in mind, they always work together: request→response. Lets look at the web server how a "normal" transactions works.Ī user-agent (browser) sends a request for a document with the URI as domain/path/documentname. we have an understanding what a redirect is. Fundamentals for redirectingįirst some fundamentals to make sure we are talking about the same thing, i.e.
#Zend redirector how to#
This page dives directly into how to redirect in PHP plus the Zend Framework. If you need some fundamentals on how a redirect works (and I think you should) then you may want to read first How does a redirect work and then come back here. There is a slight little problem: "You need to know how!" Forcing a redirect, refresh and reload of a page from within a script like PHP is also pretty simple and the same is true for the Zend Framework.

Redirecting is basically a simple procedure within HTML or rather HTTP.
