使用 ISAPI 重写在 Windows 2003 上使用 yourls.org 重定向时出现问题

发布于 2024-10-15 21:56:46 字数 1459 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

因为看清所以看轻 2024-10-22 21:56:46

好吧,这花了我一整天的时间,但我成功了。对于任何感兴趣的人来说,ISAPI 重写绝对没有任何问题。问题出在代码中。在名为 yourls-loader.php 的文件中,有一行用于检查 url、解构并重建它。问题是它总是强制新的 url 转换为 https。如果您的服务器上没有安全证书,它将无法工作!

//$scheme = ( isset($_SERVER["HTTPS"]) ? 'https' : 'http' );
//$request = str_replace( YOURLS_SITE.'/', '', $scheme . 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$request = str_replace( YOURLS_SITE.'/', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );

前两行被注释掉,这就是这里的内容。由于我信任并知道我的服务器是如何设置的(因为我自己完成了),所以我觉得不需要这个检查系统。

在 Windows 系统上需要注意的另一件事是,您还必须在此文件的开头添加建议的 Server_URI 解析。

if (isset($_SERVER['HTTP_X_REWRITE_URL'])){
    $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}

我希望这对某人有帮助......在没有在线支持的情况下,我花了一整天的时间来解决。

Ok, this took me all day, but I got it working. For anyone interested, there was absolutely nothing wrong with the ISAPI rewrite. The problem was in the code. In a file called yourls-loader.php, there's a line that checks the url, deconstructs it and reconstructs it. The problem is that it always forces the new url into https. If you've no security cert on your server it won't work!!!

//$scheme = ( isset($_SERVER["HTTPS"]) ? 'https' : 'http' );
//$request = str_replace( YOURLS_SITE.'/', '', $scheme . 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$request = str_replace( YOURLS_SITE.'/', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );

The first 2 lines are commented out, this is what was here. As I trust and know how my server is setup (cause I did it myself) I don't feel any need for this check system.

One other thing to be aware of on a Windows system is that you will have to add the suggested Server_URI parse at the start of this file too.

if (isset($_SERVER['HTTP_X_REWRITE_URL'])){
    $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}

I hope this helps someone... It's taken me all day to resolve with no online support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文