Forum Moderators: phranque
I am trying to get the anchor(index.html#123) from a URL and add it into my rewrite as a var.
Example:
site.com/index.php#abc123
would rewrite to...
site.com/script.php?anchor=abc123
I am sure this is simple, but I can't get it.
I've tried:
rewritecond %{QUERY_STRING} ^#(.*)$
rewriterule ^index.php(.*)$ /index.php?anchor=%1
and also without the # in the cond line.
The cond pattern matches when I leave out the #, but it also leaves the anchor var empty. I tested it by printing the querystring with php.
How can I get the value of the anchor in the url into a variable, so I can acces it in the script.
Thanks,
Birdman
What's also weird is that using php alone not even this returns the anchor for index.php#anchor:
<?php
$parsed = parse_url( $REQUEST_URI );
print $parsed['fragment'];
?>
Shouldn't this print "anchor"?
It doesn't. $parsed['fragment'] is empty.
JaaayyyyyDeeeeeee ...
Now, don't go hollerin' fer me... I ain't never tried this, and I know better'n to *guess* about mod_rewrite stuff - leastways in public and when everbody's sober... :)
I've never seen a local anchor in anything but the {HTTP_REFERER} var, if I recall... This is consistent with what killroy said in post#3.
Why doncha try one of them there fancy php variable-dumpin' scrips -- You know, the ones what print out the whole world to the page, and see if there's any hint of a pound-sign-URL that the server kin git aholt of in there... I reckon not, but it's worth a shot.
Back on the tractor - no, not kidding...
Jim
The reason I needed to grab the value is because the link points to a page with multiple listings and the client wants an ad to appear directly under the listing that the pages jumps to. I think it's a great idea but my original job was to get the urls friendly.
Any ideas?