Php 重定向到同一页面以定位

Php 重定向到同一页面以定位,php,redirect,Php,Redirect,需要从重定向到 我尝试了两种方法:php重定向和元刷新 PHP重定向 <?php $URL = "http://sitename.com/cat/index.php#anchor"; header("Location: $URL"); ?> <html> .... .... 元刷新 <html> <head> ... <meta http-equiv="refresh" content="0;u

需要从重定向到

我尝试了两种方法:php重定向和元刷新

PHP重定向

<?php
    $URL = "http://sitename.com/cat/index.php#anchor";
    header("Location: $URL");
?>
<html>
....

....
元刷新

<html>
    <head>
    ... 
    <meta http-equiv="refresh" content="0;url=http://sitename.ru/cat/index.php#anchor">
    ...
    </head>
...
</html>

... 
...
...
结果,我有两种方式循环页面刷新


如何正确解决此问题?

您不需要重定向页面,只需设置
窗口.location.hash

window.location.hash="anchor";

在这里尝试解决方法:谢谢。这是解决我问题的正确方法。谢谢。@xdazz不使用javascript就可以解决这个问题吗?