I have an HTML page that has several anchors on it:
<h4>Anchor 1</h4><a name="anchor1"></a>
<p>blah blah</p>
<h4>Anchor 2</h4><a name="anchor2"></a>
<p>blah blah</p>
<h4>Anchor 3</h4><a name="anchor3"></a>
<p>blah blah</p>
Then, I have a PHP array to relative paths:
$anchor_array = array(
'site/path/#anchor1' => 'Anchor 1',
'site/path/#anchor2' => 'Anchor 2',
'site/path/#anchor3' => 'Anchor 3',
);
Each site/path/
has an index.php
file inside so using .htaccess
I'm able to use a link like this:
site/path/
This works fine, but when I add the anchor to it (eg,site/path/#anchor1
) I get sent to the correct page, but not to the anchor location, just to the top of page.
What am I missing?
** EDIT **
After taking Salman A's advice, I was able to get 2/3 anchors to work properly. But one was still causing me trouble. I thought, perhaps, the browser is confusing the anchor name I have specified with something else. So I did a test and changed the anchor from anchor1
to the_anchor1
(actually, I changed it from history
to our-history
) and it works now.
Is there a reason using history
as anchor name is bad?