Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Mod_Rewrite an inner link

  • 29-11-2005 01:03AM
    #1
    Closed Accounts Posts: 36


    How can i do inner links ( e.g. <a href="#top">) with mod_rewrite. Just say i have a rewrite rule like following and i type

    www.something.com/product/4

    into the browser, i want it to be actually going to
    www.something.com/product.php#4

    RewriteRule product/4 product.php#$ [L]

    The problem is that the hash symbol is used for comments as well in .htaccess files.

    I have tried escaping the hash character and entering the ascii value but no luck.

    Has anyone ever tried this before, is it possible? Or is there a proper name for inner links so I might be able to search for an answer better.

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 2,203 ✭✭✭Serbian


    Interesting problem. I imagine you would have to handle the inner link using PHP. You could write a JavaScript function that scrolls to the product onload, and use PHP to pass the variable in. e.g.:
    RewriteRule ^product/([0-9]+)/?$ product.php?id=$1 [L]
    

    Then have a JavaScript function that will scroll to internal links when passed an id and place it in the onload even for body:

    [php]<body onload="Scroll2ID('<?=$id;?>')">[/php]

    There's a good tutorial on Sitepoint about Javascript scrolling to internal links:

    http://www.sitepoint.com/article/scroll-smoothly-javascript


  • Closed Accounts Posts: 36 chilled


    Yeah thats the probably the best option for the moment. Don't want to spend hours search for something that mightn't be possible. Cheers


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    See Extended Redirection in Engelschall's Rewrite Guide. It doesn't answer your question directly, but it should give you a starting point.

    An inner link is more commonly referred to as an anchor.

    adam


Advertisement