redirect php request to secure https host

In the following example we will direct to a specific host. This can prevent trouble with indexing your site by spiders. Then there is only one host. And any requests will be routed to your choosen host.

<?php

if ($_SERVER['SERVER_PORT'] != 443) {
    $redirect = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    header("Location: $redirect");
}

This page has been viewed 251 times. First hit: 25-Dec-2018 19:18:40
Share email, Google+, Twitter, Facebook.
comments powered by Disqus
Table