【发布时间】:2012-12-14 03:44:24
【问题描述】:
我的 URL 是 http://www.website.ro/index.php?subiect=10046&pag=1#1006,我在这里有一个没有任何操作的表单 (<form action="" method="post">)。
提交后,我正在检查一些输入字段,如果有任何错误,我想重定向。我使用此代码:
header('Location: /index.php?subiect='.$_GET['subiect'].'&pag='.$_GET['pag']); exit();
但是重定向包含 #1006 所以我的页面变成了http://www.website.ro/index.php?subiect=10046&pag=1#1006
我尝试使用以下命令更改标题中的位置:
header('Location: http://www.google.com'); exit();
带我去的页面是:http://www.google.com#1006
为什么要这样做?
我在第一行有ob_start(),我试图删除它。没有效果。重定向后的 url 仍然有 #1006。
如果我的 url 是 http://www.website.ro/index.php?subiect=10046&pag=1 并且我使用标头位置我没有问题,但如果 url 包含 #1006 则重定向后的 url 包含 to。
【问题讨论】:
-
看这个:stackoverflow.com/questions/7338853/… 看起来你无法从 PHP 中删除哈希,你必须先使用 javascript 清除它。