
When designing a website, it is sometimes necessary to redirect the user to another URL that are trying to access. This power can be performed using HTTP redirect normally, however, sometimes simply do not apply or, if you want to do with PHP, for example:
1. If the page has been some maintenance and I want to redirect users to an error page.
2. As part of a condition if you want PHP to redirect to another page, you may want to check if the user is logged in everything and if not redirected to the prompt connection.
I'm sure many other reasons that escape me at the time to write about why you want to do.
Fortunately, PHP provides a way to allow Web designers to make the control. This is done by manipulating the head of a web page before it is expressed. URL forwarding alternative page to replace the file contents:
Please note that the production must be written in the browser (including HTML tags), makes this approach work, to be the sole or first produced in the archive. So if you want to use through as a test of conditional logic at the beginning of the file, for example:
PHP open
If (loggedin == true) (
Close PHP
… HTML output can go here
PHP open
) Other (
header ( 'Location: Bogthaise = "nofollow" href = "http://www.yourURL.com"> http://www.yourURL.com ');
)
Close PHP
Go to the appropriate code this section shall open and close PHP tags is used instead of the real start and end tags with the PHP code – to run the code you need replace them with the right label start and end.
This technique is simple to control the flow control in the browser applications based on PHP. In general, if you ever want to redirect to another URL, you must use an HTTP redirect, but redirect PHP is also an option.