PHP & Javascript friendly bookmarks/query strings... ?#?#?#?

4 views
Skip to first unread message

darkflame

unread,
Jun 28, 2009, 9:29:42 AM6/28/09
to Google Web Toolkit
Ive been building a dynamic website, with the content displayed chosen
by the current contents of the history/bookmark token at the end of
the url.
eg.
/main.html#DisplayReview=220

This works great, as the whole site doesn't have to be refreshed,
hugely reducing bandwidth for me and speeding up the site for the
users. This is, of course,whats recommended to do.

My site is also, so far, completely bookmarkable this way. URLs link
directly to the current state of the app....as it should. My users
should be able to swap links just like any other site.

Problem is, I want the site to happly work when javascript is disabled
as well. If nothing else, this is needed for search-engines to index
it correctly. So I needed a way for php to display the same content
from the same links....
...only to find, to my horror, php cant seem to access anything past
the "#"...its as good as invisible!

HELP!!!

Even hiding it in a query string dosnt work
( /main?blah#DisplayReview=220.....only the blah is detected).

Now, I cant change my #'s links to ?'s...as dynamic query string
changes make the page reload, and it would completely break my history-
support.

So I'm left a bit puzzled as to what I can do.

How can I keep the sites states bookmarkable, but also have those same
URLs readable by php?
I really dont want to resort to an extra "click to get url" unless I
absolutely have too. (and besides, wouldnt that also mess up search
engine indexing? )

Ive got a vague idea that .htaccess voodoo might help me out.

Maybe htaccess can itself see the # data when the user requests the
url, and dynamically change it to a ?. (?)

I'm not hot with htaccess at all, so it might not be able to do
either, then I really am stuck.

I know htaccess stuff isnt strictly ontopic, but I'm asking here
because it seems like a common problem people building gwt sites would
have.
Unfortunately googleing this stuff is useless....(# and ? arnt exactly
mySQL-based search engine friendly querys...google dosnt seem to
support escaping your searchs).

..so I hope someone here can help.


I also hope I made myself clear.

Ian Bambury

unread,
Jun 28, 2009, 1:08:01 PM6/28/09
to Google-We...@googlegroups.com
You can't do it. The server doesn't get sent the stuff from the # onwards.

Thomas Wrobel

unread,
Jun 28, 2009, 2:32:38 PM6/28/09
to Google-We...@googlegroups.com
-sigh-
Well, at least thats a clear cut answer ;)
Pitty.
Guess I'll have to use a "click here to get url" button and try to
restructure any outgoing links pointing back to use a ? query for the
search engines sake.


2009/6/29 Ian Bambury <ianba...@gmail.com>:

Ian Petersen

unread,
Jun 28, 2009, 3:30:09 PM6/28/09
to Google-We...@googlegroups.com
I don't know if this will help you, but maybe you're thinking about
the problem backwards. "Javascript-enabled" is a pretty flexible
environment--at least more flexible than "Javascript-disabled". Maybe
the canonical URLs should be PHP-visible, and the Javascript-enabled
version should somehow munge the URLs on the client side to avoid
reloads. Search for "hijax" and see if it helps you come at the
problem from a different angle.

Ian

Ian Bambury

unread,
Jun 28, 2009, 4:08:33 PM6/28/09
to Google-We...@googlegroups.com
What you need is a non-js site structure which matches your gwt structure except for the ? and #

Without the #stuff, the search engines will go to the index page and just recursively find all your non-js structure.

The search engines display site.com/?thing=220 etc and that will be the link in the serps. Non-js users will get that non-js page.

But...js users get to execute a little script which replaces the ? with a # and redirects them to the gwt site but with the right bookmark to see the right gwt page.

Not absolutely ideal because visitors from the serps get an initial (albeit invisible) redirect, and any sites that cut and paste from the address bar will point search engines to the index page, and you need to structure your site in the right way to make the non-js site trivial (mine is just 3 PHP pages).

But it's better than not doing it IMO.

Contact me off-list if you want to see if my way of doing it could work for you

Cheers,

Ian

http://examples.roughian.com


2009/6/28 Thomas Wrobel <dark...@gmail.com>

Thomas Wrobel

unread,
Jun 28, 2009, 4:16:58 PM6/28/09
to Google-We...@googlegroups.com
Thats actualy really interesting (hijax) I never thought about a site
constructed like that.
I think that could work for me, unfortuntely its far too late in the
game for me to take that approach, not just the re-writing but the
"mental shift" is a bit much at this stage.
But I'll bare it in mind for future because that seems a rather
elegant way to write ajax/php sites.

~~~~~~
Reviews of anything, by anyone;
www.rateoholic.co.uk
Please try out my new site and give feedback :)



2009/6/29 Ian Petersen <ispe...@gmail.com>:

Thomas Wrobel

unread,
Jun 28, 2009, 4:24:56 PM6/28/09
to Google-We...@googlegroups.com
That seems a fairly good approach to take.

I think that will work for me. Not perfect, but it will do.
My site probably needs just two php scripts..one to display a set of
search results, and one to display a specific result. (+the homepage
which is already a purely php-thing, Gwt parsers its html on loading).
So it shouldn't take too much adjustment.

I'll try to make the adjustments myself over the next few days. I'll
let you know how I get on :)


2009/6/29 Ian Bambury <ianba...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages