我在加载模板时遇到问题,我尝试在 XAMPP 上测试我的模板,但同样的问题再次发生
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at admin@main-hosting.eu to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.`
一开始它没有显示任何内容,只是加载页面,然后错误就不再出现了...请帮忙,但在 XAMPP 上它只是不断加载我的页面 但过了一段时间,当我试图解决问题时,找到了它并尝试解决它,但我需要一些帮助来修复之前导致它的代码
$Domain = $_SERVER['HTTP_HOST'];
$Path = $_SERVER['PHP_SELF'];
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS']))
{
echo '<script type="text/javascript">window.location.assign("https://' .$Domain.$Path. '");</script>';
}
else
{
echo '<script type="text/javascript">window.location.assign("http://' .$Domain.$Path. '");</script>';
}
请帮忙???
最佳答案
原因是因为每次加载页面时脚本都会运行并不断刷新网站。您需要知道页面是否已被重定向。 示例:
<?php
if (!isset($_GET['r'])){
$Domain = $_SERVER['HTTP_HOST'];
$Path = $_SERVER['PHP_SELF'];
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS']))
{
echo '<script type="text/javascript">window.location.assign("https://' .$Domain.$Path. '?r=https");</script>';
}
else
{
echo '<script type="text/javascript">window.location.assign("http://' .$Domain.$Path. '?r=http");</script>';
}
}
?>
我不明白这一点。我建议您改用位置。示例:
header('Location: http://www.example.com/');
关于PHP-检测HTTPS协议(protocol)的一些问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44515522/