To redirect the current page to a different location you use the header() function in the following way:
You can use this function when you want to point the user to a different page. If you are writing a login script then this function would be useful to show the user a certain page depending on them entering the correct user information.
To send a code along with the redirect (for example, a 301) you can use the optional parameters. The second parameter is a boolean value that determines if this header call should replace any headers of a similar name. For example, if you send a header called "Cache-Control" and then send another header later on with the same name then the second parameter determines if the value is replaced or appended. If the value is true then the previous value is overwritten, if the value is false then the value is appended to the list of headers being sent.
The third parameter is the code to be issued along with the header. So to create a 301 redirect do the following.