3. satıra aşağıda ki kodları ekledikten sonra tekrar deneyip ekranda yazan hatayı buraya iletebilirmisiniz.
error_reporting(E_ALL);
ini_set('display_errors', 1);
Ayrıca REQUEST_URI ile ilgili bir hata olmaması için 5. satır ile 19. satır arası aşağıda ki gibi olursa daha iyi olur.
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off" || strpos($_SERVER['HTTP_HOST'], 'www.') !== false) {
    if(strpos($_SERVER['HTTP_HOST'], 'www.') !== false){
        $location = 'https://' . str_replace('www.','',$_SERVER['HTTP_HOST']) . $request_uri;
        header('HTTP/1.1 301 Moved Permanently');
        header('Location: ' . $location);
        exit;
    }else{
        $location = 'https://' . $_SERVER['HTTP_HOST'] . $request_uri;
        header('HTTP/1.1 301 Moved Permanently');
        header('Location: ' . $location);
        exit;
    }
}
 
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$request_uri";