为什么我的 CGI 脚本不断将链接重定向到本地主机?

发布于 2024-10-09 01:08:32 字数 766 浏览 0 评论 0原文

访问此页面http://online-file-sharing.net/tos.html并单击底部页脚链接之一。它将您重定向到地址栏中的本地主机。我不知道它为什么这样做。

这是我的整个网站围绕的主脚本:

upload.cgi

$ENV{PATH} = '/bin:/usr/bin'; 
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
($ENV{DOCUMENT_ROOT}) = ($ENV{DOCUMENT_ROOT} =~ /(.*)/);
# untaint. #$ENV{SCRIPT_NAME} = '/cgi-bin/upload.cgi';
use lib './perlmodules';
#use Time::HiRes 'gettimeofday';
#my $hires_start = gettimeofday();
my (%PREF,%TEXT) = (); 

当有人访问根目录时,不会显示任何文件,尽管我有一个 .htaccess 文件说要打开位于我的根目录中的 upload.cgi 文件。

当我将浏览器直接指向 CGI 文件时,它可以工作,但它会再次将我带到本地主机。

我将此网站托管在我自己的服务器(即这台计算机)上,如果此信息有帮助,我会使用 XAMPP。我还使用 DynDNS 作为我的名称服务器。

我希望你能给我一些见解。

Visit this page http://online-file-sharing.net/tos.html and click one of the bottom footer links. It redirects you to your localhost in the address bar. I have no idea why it does this.

This is in the main script that my entire website revolves around:

upload.cgi

$ENV{PATH} = '/bin:/usr/bin'; 
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
($ENV{DOCUMENT_ROOT}) = ($ENV{DOCUMENT_ROOT} =~ /(.*)/);
# untaint. #$ENV{SCRIPT_NAME} = '/cgi-bin/upload.cgi';
use lib './perlmodules';
#use Time::HiRes 'gettimeofday';
#my $hires_start = gettimeofday();
my (%PREF,%TEXT) = (); 

No file is displayed when someone visits the root directory, although I have a .htaccess file saying to open my upload.cgi file which is located in my root directory.

When I point my browser directly to the CGI file it works but it brings me to my localhost again.

I'm hosting this website on my own server, which is this computer, and using XAMPP if this information helps. I'm also using DynDNS as my nameservers.

I hope you can give me some insight.

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

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

发布评论

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

评论(2

强辩 2024-10-16 01:08:32

好吧,只要查看 HTML 的源代码就会发现 localhost 实际上是链接的一部分。使您的链接具有相关性。例如,如果我给你这个 URL:

http://localhost/foobar

总是带你到本地主机。如果你的情况,你想要的是 /foobar ,表明它应该从当前主机的根目录开始,并添加 foobar 路径。

Well, just looking at the source of the HTML reveals that localhost is actually part of the link. Make your links relative. For instance, if I gave you this URL:

http://localhost/foobar

It's always going to take you to localhost. If your case, what you want is /foobar, indicating that it should start at the root of whatever the current host is, and add add the foobar path it.

一百个冬季 2024-10-16 01:08:32

你用什么来生成 HTML?很明显,您不是手写的,或者您已经有了问题的答案,但听起来您导致超链接计算不正确。您想要的是一个以 / 开头的链接,这意味着您已经所在的任何域的根目录,或者相对于当前目录的路径。

What are you using to generate HTML? It's fairly obvious you're not writing this by hand or you'd already have the answer to your question, but it sounds like you're causing the hyperlinks to be calculated incorrectly. What you want is a link starting with /, meaning the root of whatever domain you're already in, or a path relative to the current directory.

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