Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Mod_Rewrite an inner link

  • 29-11-2005 12: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,170 ✭✭✭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