Jump to content

Need PHP to get hash from url


oskom

Recommended Posts

Hey all,

Is there some $_SERVER method, or anything else, that will allow PHP to get the hash from a url? In other words, I want to take a url like "www.mydomain.com/#1234" and have PHP get the hash and use it as a variable for other purposes.

 

Does this sound do-able?

Link to comment
Share on other sites

That's exactly what I'm trying to avoid. I don't want to pass it as a variable. This is for an all AJAX site where the unique url's(in theory) will be created in the hash. I can create a particular page from javascript with the hash, but I need to do it with PHP instead...Google searchable!!!! The only way I can make a unique url for each page(i.e. effect the address without actually flipping the page) is to hash it with javascript. I need to then be able to cut-n-paste that url with the hash into another browser window and have PHP build the page based on the hash being turned into a variable PHP can use.

 

I hope that wasn't too confusing. Can I achieve that with PHP?

 

Here's an idea: can I cookie the hash and pass that?

Link to comment
Share on other sites

Well it sounds like you're doing something more complex than I was thinking. I'm not too sure how you'd do that, to be honest. But stepping back a bit and thinking about it, I think a cookie may be the best way without passing it visibly?

Link to comment
Share on other sites

$hash = substr(strrchr('#', $_SERVER['REQUEST_URI']), 1);

 

DarkWater,

In testing, it doesn't appear that $_SERVER['REQUEST_URI'] passes the hash. Otherwise, yes, that would be my method. Unfortunately, PHP isn't getting a hash to sub-string.

 

hmmmmmm...

Link to comment
Share on other sites

I just checked it out online. Yes, it looks like javascript. Not sure what the difference is yet, though. However, in thinking about it some more, I don't know that the cookie is the solution either. You would have to establish the browser-side cookie with javascript first, then redirect the page(cookie in place) to a PHP page. With Google-searchability at stake, is the googlebot going to be able to take that step? Or does that small amount of javascript intervention break the deal?

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.