免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4971 | 回复: 3
打印 上一主题 下一主题

[Web] 如何禁止apache或tomcat的HTTP/1.1 301 Moved Permanently [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-22 19:50 |只看该作者 |倒序浏览
服务器是:FreeBSD+Apache+Tomcat

apache解析静态文件
ajk连接
tomcat解析jsp

/var/www/app目录下有两个文件:154.rar与145.rar,后把154.rar移走到其它目录下

1、下载 http://www.test.com/app/154.rar,返回145.rar,明显不对,用php的get_headers查看了http请求,原来301在做怪。

下载http分析:
var_dump(get_headers("http://www.test.com/app/154.rar"));
array(13) {
  [0]=>
  string(30) "HTTP/1.1 301 Moved Permanently"
  [1]=>
  string(35) "Date: Fri, 22 May 2009 15:23:25 GMT"
  [2]=>
  string(14) "Server: Apache"
  [3]=>
  string(36) "Location: http://www.test.com/app/145.rar"


2、尝试在apache"禁止"301(添加ErrorDocument 301 /missing.html),访问http://www.test.com/app,产生404,原来是可以的,自动转向到http://www.test.com/app/index.jsp

添加语句前,有Location: http://www.test.com/app/
var_dump(get_headers("http://www.test.com/app"));
array(13) {
  [0]=>
  string(30) "HTTP/1.1 301 Moved Permanently"
  [1]=>
  string(35) "Date: Fri, 22 May 2009 15:23:25 GMT"
  [2]=>
  string(14) "Server: Apache"
  [3]=>
  string(36) "Location: http://www.test.com/app/"

添加语句后,直接返回/missing.html
var_dump(get_headers("http://www.test.com/app"));
array(9) {
  [0]=>
  string(30) "HTTP/1.1 301 Moved Permanently"
  [1]=>
  string(35) "Date: Fri, 22 May 2009 19:36:01 GMT"
  [2]=>
  string(14) "Server: Apache"
  [3]=>
  string(44) "Last-Modified: Sat, 04 Apr 2009 17:52:47 GMT"

3、现在的问题是,如何让apache或tomcat下载不存在的文件时,产生http 404状态,而不是301;虽然154.rar与145.rar很像(154.rar已移走),但不是同一个文件,如何更正apache或tomcat的错误。

多谢!

论坛徽章:
0
2 [报告]
发表于 2009-05-26 10:57 |只看该作者
自己顶一下

论坛徽章:
0
3 [报告]
发表于 2009-05-26 13:07 |只看该作者
关闭 mod_speling

# LoadModule speling_module modules/mod_speling.so

论坛徽章:
0
4 [报告]
发表于 2009-06-02 14:01 |只看该作者
关掉mod_speling,OK,困扰很久的问题,终于搞定

非常感谢,jhsea3do
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP