PHP & MySQL | Tutorials

David Carr

PHP Redirect

Tutorial on PHP redirect to be redirected to another page or web site

For this tutorial lets suppose you have moved your web site to another domain and want your visitors to be redirected to your new domain you can use PHP for this purpose.

Here is the code to redirect a user:

header('Location: http://www.dcblog.dev');

Here's a breakdown of the code.

The <?php tells the browser to expect to receive php.

header ('Location: 'http://www.dcblog.dev'); tells the browser to redirect to the address given in the code and ?> tells the browser to finish expecting PHP.

Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2021 DC Blog. All code MIT license. All rights reserved.