<?php
header(
"Location:https://www.nowamagic.com"
);
?>
当访问 http 时,跳 https:
<?php
//http转化为https
if
(
$_SERVER
[
"HTTPS"
] <>
"on"
)
{
$xredir
=
"https://"
.
$_SERVER
[
"SERVER_NAME"
].
$_SERVER
[
"REQUEST_URI"
];
header(
"Location: "
.
$xredir
);
}
?>
当访问 https 时,跳 http:
<?php
//https转化为http
if
(
$_SERVER
[
"HTTPS"
] ==
"on"
)
{
$xredir
=
"http://"
.
$_SERVER
[
"SERVER_NAME"
].
$_SERVER
[
"REQUEST_URI"
];
header(
"Location: "
.
$xredir
);
}
?>
在网页开头包含上面代码即可。
转载请注明:XAMPP中文组官网 » php访问http变成https解决办法