【发布时间】:2013-10-17 22:27:50
【问题描述】:
我正在使用 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"}
这是 Windows 7。我正在使用管理员帐户运行 Chrome。
一段时间后,我还没有找到解决问题的方法。我想我应该为专家提供更多细节来重现我的问题。 关于我的httpd.conf,我在原来的基础上换了地方: 第 193 行:
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
我删除了 2 行:
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。
【问题讨论】:
-
显示您的
.htaccess。 -
我在 conf 文件夹中搜索但没有找到 .htaccess。 Apache2.2/manual 文件夹下只有 htaccess.html,我觉得不是你说的配置文件。
-
对同一目录的其他请求(例如
/image.jpg)是否也被禁止或只是.pl文件? -
我可以从命令行运行它:cgi-bin>get_data.pl
-
你安装了
mod_perl吗?