Rah*_*hul 1 xampp perl cgi nph
我创建了一个名为"nph-select.pl"的文件,并将代码放入重定向,如下所示.
#!"D:\xampp\perl\bin\perl.exe" -w
use CGI qw/:standard/;
my $cgi = new CGI;
print $cgi->redirect(-uri => 'http://www.google.com/', -nph => 1);
Run Code Online (Sandbox Code Playgroud)
并执行文件然后它给我302状态消息说"文件已移动到这里".但是,当我重命名同一个文件时只需删除" - ",即新文件名是"nphselect.pl",然后它也可以正确运行重定向.任何人都可以建议我缺少什么设置?
我的请求标题是
Host localhost:8080
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Host localhost:8080
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
并且响应标题是空白的.
首先,一些web服务器以不同于任何其他cgi脚本的方式处理以'nph-'开头的cgi脚本,因此删除 - 将改变它.
你正在调用重定向错误; CGI的命名参数都必须以 - 开头 - ,像这样:
print $cgi->redirect(-uri => 'http://perl.about.com/');
Run Code Online (Sandbox Code Playgroud)
随着uri代替-uri,它是使用位置参数,所以它试图重定向到"网址"(这你的服务器可能会完全符合你).
如果你是想使用nph-脚本,设置重定向的NPH选项提供更全面的套头; 这可以解决您的问题:
print $cgi->redirect(-uri => 'http://perl.about.com/', -nph => 1);
Run Code Online (Sandbox Code Playgroud)