How to make php redirect to page?

kristen

New member
Hi guys, I need to use a redirect with php, not just domain redirect with .htaccess.
Any ideas?
 

Stacey

New member
1. You can use the header() function to send a new HTTP header, but this must be sent to the browser before any HTML or text (so before the <!DOCTYPE ...> declaration, for example):

2. Alternatively, you may use method of http_redirect($url); which needs the PECL package pecl to be installed.

If you will use 1st method, don't forget to add die() or exit() in the end:
header("Location: http://example.com/myOtherPage.php");
die();