Forum Moderators: phranque

Message Too Old, No Replies

Advanced Mod_rewrite

using the # tag in the htaccess file

         

irldonalb

5:19 pm on Aug 23, 2004 (gmt 0)

10+ Year Member



Hi Guys,

In the htaccess file I have successfully redirected
^my_page.\htm$ /my_page\.php

But I also need to redirect the bookmark value on the page.

So the page [domain.com...] will redirect to [domain.com...] At present the bookmark is working, but I need to get the id value.

I've tried

^my_page.\htm#(.*)$ /my_page\.php?id=$1 but id is coming out blank. Any ideas?

Thanks
Donal

coopster

5:35 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yeah, that value does not get passed. We had an in-depth conversation on this once in the PHP forum. We found reference and other discussion regarding Getting anchor from URL [webmasterworld.com], but nothing definitive. Turns out, you'll find the details in the RFC. See Parse URL with a hashmark (#) [webmasterworld.com] for an enlightening discussion.

irldonalb

9:37 am on Aug 24, 2004 (gmt 0)

10+ Year Member



Ok after further study (and help from coopster) I found out that it is NOT possible to get the value after the hash sign in PHP as it is not past to the server.

But I needed the value to store some data in my database so there was no reason I couldn’t do this AFTER the page was loaded.

So I created the following JavaScript function,

<script language="JavaScript">
<!--
var rj_site = location.hash.substring(1);
var rj_img = new Image();
rj_img.src = 'http://localhost/links/page_viewed.php?id='+rj_site;
-->
</script>

After the page is loaded I can save the hash value into the database. It's not pretty but it works.

Donal