PHP中window.location.origin的替代

时间:2019-01-31 02:34:40

标签: php html window.location

我要在不更改/ abc的情况下将domain1.com/abc重定向到domain2.com/abc,它应该相同,但只应更改域。我的意思是,之后/一切都应该相同,只有/之前的域应该更改为domain2。就像我使用脚本一样:-

public partial class Employee
{
    public int EmployeeId { get; set; }
    public string Name { get; set; }
    public string userName { get; set; }
    public string userRole { get; set; }

    // Foreign Key
    public int CountryId { get; set; }
    // Navigation Property
    public virtual Country EmployeeCountry
}

public partial class Country
{
    public int CountryId { get; set; }
    public string Country_Name { get; set; }
}

1 个答案:

答案 0 :(得分:0)

使用Location HTTP标头。

使用请求的域和值为$_SERVER['REQUEST_URI']的值构建标头值:

<?php

$domain = 'http://domain2.com';
$location = $domain . $_SERVER['REQUEST_URI'];
header('Location: ' . $location);