We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18862
    • 70 Posts
    Does anyone know if there is a special rule that needs to be added to .htaccess in order for links to pages with an anchor reference to work? ie: http://www.whatever.com/mypage.html#anchor

    From the googling I’ve done it seems like this problem relates to mod_rewrite and how it’s unable to handle a direct link to a page with an anchor because same-page anchors are handled locally by the browser.

    And yet, I see that in the modx forums you can copy a link to a particular message: ie: http://modxcms.com/forums/index.php/topic,whatever.msg1111.html#msg1111 (this doesn’t actually go anywhere.. just giving as an example) and you can go directly to it.

    When I try it with my site instead it takes you to the page, but not to the anchor on the page. If I highlight the address in the browser and press enter again, then it will jump down to the anchor.

    So the problem is when it first loads the page, it will not jump down to the anchor. Then if I reload the page then it will jump down to the anchor.

    Anyone have experience with this?
      • 22840
      • 1,572 Posts
      Im using the following and it works great:

      <div id="index">
      <ul class="index">
      <li><a href="#a">A</a></li>
      
      </ul>
      </div>
      <div class="letter" id="a">A</div>
      
        • 18862
        • 70 Posts
        Yes, that works fine if you are using a link on the same page to jump down to an anchor or a tag with an ID on the same page after the page has already loaded. That’s the whole problem for me.

        I’m trying to have it where you can go directly to an anchor on a page when it first loads.

        Try going directly to your anchor by putting the url directly into a page and see if it goes right to your link.

        ie:

        www.yoursite.com/yourpage.html#a