301 redirect html code example
Example 1: php 301 redirect
<?php // Permanent 301 Redirect via PHP
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://domain.tld/new/location/");
exit();
?>
Example 2: 301 redirect http to https
#For apache .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]