1<?php // Permanent 301 Redirect via PHP
2 header("HTTP/1.1 301 Moved Permanently");
3 header("Location: http://domain.tld/new/location/");
4 exit();
5?>
1301, "Moved Permanently"—recommended for SEO
2302, "Found" or "Moved Temporarily"
3Meta Refresh
1#For apache .htaccess
2RewriteEngine On
3RewriteCond %{HTTPS} off
4RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
1#http to https and www to non-www
2RewriteEngine On
3RewriteCond %{HTTPS} off [OR]
4RewriteCond %{HTTP_HOST} ^www\. [NC]
5RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
6RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]