13

Need make redirect from http://sitename.com/cat/index.php to http://sitename.com/cat/index.php#anchor

I tried 2 ways: php redirect and meta refresh

PHP redirect

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

meta refresh

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

In result to both ways I have cycling page refresh.

How to correctly solve this problem ?

rav_kr
  • 434
  • 8
  • 16
v2p
  • 649
  • 2
  • 10
  • 19

1 Answers1

9

You don't need to redirect the page, just set the window.location.hash.

window.location.hash="anchor";
xdazz
  • 158,678
  • 38
  • 247
  • 274