【问题标题】:Not using the url from a header redirection不使用来自标头重定向的 url
【发布时间】:2017-03-29 14:21:22
【问题描述】:

我正在使用标题重定向返回到我网页上的页面跳转点。我用header('Location: index.php#contact'); 做到了这一点。

我现在的问题是它说

www.pagename/index.php#contact

问题是我不想在我的网址中看到#contact,我该如何解决这个问题?

顺便说一句,我使用header('Location: index.php#contact'); 的页面与我拥有锚点的页面不同。

【问题讨论】:

  • 不确定这对您是否有用,但请查看此链接:stackoverflow.com/questions/8272215/…
  • 不,这没有帮助,因为它没有发生在同一页面上。
  • 如果你想让标签转到文件中的那个地方,你需要一个 JS 解决方案来使用标签
  • 充其量;使用完整的 http 调用。即:header('Location: http://www.example.com/index.php#contact');
  • www.pagename 再次,请参阅 ^

标签: php .htaccess mod-rewrite url-redirection


【解决方案1】:

我建议您在 [index.php] 添加一些 javascript 代码来更改 URL。像这样:

echo "<script type='text/javascript' language='javascript'>
    history.pushState({},\"index.php#contact\",\"index.php\");
</script>";

第二个参数是原始网址,第三个参数是要显示的网址。

就是这样。O(∩_∩)O~

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-29
    • 1970-01-01
    • 2015-07-04
    • 2021-09-10
    • 2019-02-27
    • 1970-01-01
    • 2012-01-21
    • 1970-01-01
    相关资源
    最近更新 更多