免费注册 查看新帖 |

Chinaunix

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

[Web] [rewrite模块]PHP的header()发送的location会不会被重写 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-07-28 12:40 |只看该作者 |倒序浏览
我只是想到这个,没有实践的环境。哪位方便的可以帮我试试?

比如把 http://localhost/1 rewrite 成 http://localhost/index.php?id=1
那我在 index.php 里 header("location: http://localhost/2"; 会不会被重写成 http://localhost/index.php?id=2

最好不要叫俺去看 http 协议,我会死的

我猜测 rewrite 应该只会针对浏览器端的请求, header 函数是 php 解析器叫 web server 发送 header 信息给浏览器端,所以不应该被重写? 不知道是否这样?

论坛徽章:
0
2 [报告]
发表于 2006-07-28 13:20 |只看该作者
你的意思没明白?
你想做什么?
仅仅转向?

论坛徽章:
0
3 [报告]
发表于 2006-07-28 13:56 |只看该作者
这个... ? 我咋解释好呢? 这样说吧:

我使用 apache 重写模块定义了一个规则,使得浏览器访问 http://localhost/1 会被重写成 http://localhost/index.php?id=1

现在我在 index.php 程序里有这么一段代码:

header("location: http://localhost/1") ;

那浏览器访问 http://localhost 的时候,会不会因为上面的代码,URL 被重写成 http://localhost/index.php?id=1

论坛徽章:
0
4 [报告]
发表于 2006-07-28 16:07 |只看该作者
先redirect到http://localhost/1
然后rewrite到http://localhost/index.php?id=1

rewrite过程后面有参数的,如果是[R],apache会发送个header,浏览器地址会改变。
如果是[P],则不会。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP