Domain Redirection Using a PHP Script

Domain redirection can be achieved using a PHP script. Here’s an example script that redirects the user to a new page:

<?php
header("Location: https://example.com/newpage.php");
exit;
?>

In this example, replace https://example.com/newpage.php with the URL of the page that you want to redirect the user to. This script uses the header function in PHP to send an HTTP header to the user’s browser, indicating that the page has moved to a new location. The exit function is used to terminate the script after the header has been sent, to prevent any further output from being sent to the browser.

Save this code in a file with a .php extension, for example redirect.php. Then, upload the file to the root directory of the domain that you want to redirect. When a user visits the original domain, the script will be executed and the user will be automatically redirected to the new page.

Leave a Comment