Apache url无法访问
问题描述:
我必须检查apache服务器的访问权限。我写了一个独立的代码来检查apache服务器的访问权限。如果我简单地键入URL是accessable ...但闻一运行它通过它的代码抛出异常..Apache url无法访问
为java.io.IOException异常:服务器返回的HTTP响应代码:403网址:http://10.98.12.151:80/server-status?auto
什么是403响应码? hw我可以让它从独立代码访问...
这是我的代码 connecturl =“http://”+ ip +“:”+ port +“/ server-status?auto”; 012URtargetURL = new URL(connecturl); HttpURLConnection httpURLConnection =(HttpURLConnection)targetURL.openConnection();
httpURLConnection.setUseCaches(false);
httpURLConnection.setAllowUserInteraction(false);
httpURLConnection.setDoInput(true);
httpURLConnection.setRequestMethod("GET");
httpURLConnection.connect();
答
403代码是“访问被拒绝”代码。其他代码定义可以在w3.org
原因可能是由于httpd.conf文件中的指令没有包含您尝试运行该程序的主机的IP的“允许来源”。
例如,您正在尝试从客户端(10.98.12.10)运行此操作并希望检查您在10.98.12.151上运行的Web服务器的状态。
确保服务器上的httpd.conf文件有类似以下内容:
<Location /server-status> SetHandler server-status Order deny,allow Deny from all # now make sure your client host is allowed to connect to this location Allow from 10.98.12.10 </Location>
好运。
http://en.wikipedia.org/wiki/HTTP_403 你错过了文件的扩展名吗? – Chumillas 2011-05-30 10:34:28