Jump to content

can PHP read fragments (after hashmark #anchor) from URL?


micah1701

Recommended Posts

if the url is my-domain.com/some_page#here_is_an_anchor is there anyway to read that anchor value server side?

parse_url() shows that it can parse the value, but the examples for that function are setting the value of the URL as a string, hard-coded into the script.  I need to detect the URL dynamically.

 

My suspicion is that this is impossible but I figured it can't hurt to ask.  Thanks for any advice.

Link to comment
Share on other sites

thanks for your input. Seems to firm up what I'm coming to realize, its just not possible.

 

I have an ajax based page that loads content with javascript and simultaneously appends the url with a /#!/shebang tag to keep it SEO friendly with google.  The only problem is, if JS isn't enabled, obviously the content can't load. I wish I could still use the anchor tag urls AND preload the content.  Oh well.  Guess its back to old fashioned ?variables=in_the_url  :(

Link to comment
Share on other sites

what you're describing isn't an anchor, it is actually part of the url and can be grabbed. for instance, twitter picks up stuff after /#!/ in

 

http://twitter.com/#!/SalonsOnline

 

you can use mod_rewrite and/or PHP to redirect or passthrough based on whatever is after #!

 

well perfect. thats my question, how can php (or htaccess) get that value?

 

i did a print_r($_SERVER) and don't see #! anywhere in there.  Where can I get the value of the URL to parse server-side?

 

EDIT:  turn off javascript and try that link to twitter again. It doesn't redirect. They're using javascript to detect the hashbang in the URL and redirect the browser.  Seems to indicate that this is still impossible  :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.