[英]Apache 403 error (Forbidden) on windows
我正在使用Apache,并使用jQuery从index.html
发送ajax请求。 get_data.pl
是cgi-bin
上的文件。 我收到403 Forbidden error
。 任何人都会帮助我,在此先感谢。
$.ajax({
async : true,
type: "GET",
url: "get_data.pl"
}).done(function(msg){
alert("Data Saved: " + msg);
}).fail(function(xmlHttpRequest,statusText,errorThrown) {
console.log(JSON.stringify(xmlHttpRequest));
console.log(statusText);
console.log(errorThrown);
});
我从控制台得到的是:
{"readyState":4,"responseText":"<!DOCTYPE ...<title>403 Forbidden</title>...
<p>You don't have permission to access /get_data.pl\non this server.</p>\n</body>
</html>\n","status":403,"statusText":"Forbidden"}
它是Windows7。我正在使用管理员帐户在Chrome上运行。
一段时间后,我仍未找到解决该问题的方法。 我想我应该为专家提供更多细节来重现我的问题。 关于我的httpd.conf,我根据原始位置(第193行)更改了位置:
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
我删除了两行:
Order allow,deny
Allow from all
343行:
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
我将此部分更改为:
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin">
AllowOverride None
Options +ExecCGI
AddHandler cgi-script .cgi .pl
Allow from all
</Directory>
我将.pl文件放在cgi-bin文件夹中,将index.html放在htdocs文件夹中。 我尝试了Windows7,Win2k3 64位和WIn2k3 32位。 所有都有禁止的错误。 我也使用了Apache的默认printenv.pl。
我认为您缺少运行CGI
内容的权限,可以在Apache文档中阅读有关如何启用它的信息。
简而言之,在您的主配置文件( https.conf
)中https.conf
:
<Directory /path/to/cgi-bin/>
Options +ExecCGI
AddHandler cgi-script .pl
</Directory>
希望它能帮助您前进。
编辑
问题是用于访问脚本的路径不正确。 日志文件显示Options ExecCGI is off in this directory: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/get_data.pl"
而get_data.pl
文件不在htdocs
,而在cgi-bin
在ajax
调用中更改url: "get_data.pl"
以在cgi-bin
找到脚本解决了该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.