PHP redirect

PHP redirect from page to URL. PHP 301 redirect.

This PHP redirection should return HTTP response status code: 301 Moved Permanently.

Search engines use the 301 response status code to transfer the page rank from the old URL to the new URL.

PHP header redirect

Replace old-page.php code with redirection code to new-page.php.

old-page.php:

<?php
// PHP permanent URL redirection
header("Location: http://www.domain.com/new-page.php", true, 301);
exit();
?>

The old page must have .php file extension.

The new page can be with any extension.

PHP redirect examples

Example #1

php-redirect.php

<?php
// PHP permanent URL redirection test
header("Location: https://www.justfreetools.com/en/web-design/web-development/php-redirect.php", true, 301);
exit();
?>

Press this link to redirect from php-redirect-test.php back to this page:

PHP redirect - PHP file

Example #2

php-redirect-test.htm

<?php
// PHP permanent URL redirection test
header("Location: https://www.justfreetools.com/en/web-design/web-development/php-redirect.html", true, 301);
exit();
?>

PHP redirection from html file php-redirect-test.htm usually will not work because of the .html file extension, unless it is enabled in the .htaccess or httpd.conf file:

PHP redirect - HTML file

To enable PHP in HTML files add this code to the .htaccess or httpd.conf file:

Addtype application/x-httpd-php .htm .html

URL redirection »


Currently, we have around 935 calculators, conversion tables and usefull online tools and features to make your life easier or simply help you to do your work or duties faster and in more effective way. These below are the most commonly used by many users at all

And we are still developing more. Our goal is to become the one-stop, go-to site for people who need to make quick calculations or who need to find quick answer for basic conversions.

Additionally, we believe the internet should be a source of free information. Therefore, all of our tools and services are completely free, with no registration required. We coded and developed each calculator individually and put each one through strict, comprehensive testing. However, please inform us if you notice even the slightest error – your input is extremely valuable to us. While most calculators on Justfreetools.com are designed to be universally applicable for worldwide usage, some are for specific countries only.


This website uses cookies to improve your experience, analyze traffic and display ads. Learn more