开发者

Why does my CGI script keep redirecting links to localhost?

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 开发者_StackOverflow社区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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜