301 Redirection with PHP

- 1 min read
PHP logo
PHP logo

Sometimes you might want to redirect your visitors to a new URL address. One reason you may want to do this is that the page they are trying to access no longer exists.

There are 3 types of redirection, 301, 302 and 303. ‘Redirection 301’ is for that pages that are moved permanently.

In PHP, we can make a 301 with the following code:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.new-location.com");
exit();

Share: Link copied to clipboard

Tags:

Previous: Parque de atracciones Wunderland Kalkar (Antiguo SNR-300)
Next: 301 Variable Redirection with PHP

Where: Home > Technical > 301 Redirection with PHP