views:

24

answers:

2

I am new to deep linking, so not sure how to do this. In order for the web site to be crawl able by all crawlers, I am using Hijax method which basically means all my links are tagged as follows:

<a href=”index.php?foo=32” 
   onClick=”navigate('index.php#foo=32'); return false”>Link</a>

Due to this schema all of the pages on the web site are replicated in AJAX and in PHP (I use same PHP files to generate data for both, so I am not really retyping the code twice in PHP and Javascript).

Basically what happens is that on the initial load of the page PHP generates the HTML content of the page and then AJAX alters the content according to the hash value (#foo=32) whenever user goes to a link on the page. This allows search browsers to index the site since PHP generates all the content for every page, and users with support for AJAX get to can enjoy AJAX if they navigate to a different page on the site.

What I am having trouble with is the following. My home page loads simply as index.php. According to the specs of the URL fragment, fragments are NOT sent to the server - meaning PHP can't know if the user typed a fragment in the URL. So, lets say the user bookmarks the page with the URL index.php#foo=32, whenever user will try to load that page, since PHP does not know that the fragment was added to the URL, the sever returns the HTML code of the home page, and as soon as the home page is loaded, document.onload event is triggered and Javascript (I am using SWFAddress library to deep link) checks the hash value and alters the page to display whatever index.php#foo=32 is suppose to display. I don't like this because it is inefficient and is not very user friendly. User has to see the home page and only then something reloads.

So, the question is: How is this approached in the industry or how should I design things so that the home page is not loaded when user tries to access index.php#foo=32.

Thank you in advance. I would appreciate any help.

EDIT:

Here is the idea of Hijax described which enables AJAX deep linked sites to be indexable by crawlers: http://googlewebmastercentral.blogspot.com/2007/11/spiders-view-of-web-20.html

A: 

I would tackle the problem using javascript, rather than PHP, since PHP can't see the see the fragment. Something like the following placed in a script tag just before the closing body tag of your page would do it:

window.load = function() {
    var hashpart = window.location.hash;
    if (hashpart != '') {
        navigate('index.php#' + hash);
    }
}

While I'm talking about javascript, I'd also recommend not using onClick attributes. Best practice these days is to use unobtrusive scripting, however, that's totally unrelated to your question.

Horatio Alderaan
I have to use PHP in order search crawlers to be able to index pages. You can read the Google link I posted which explains the idea. Thanx for the hint on unobtrusive scripting. I did not know that.
miki725
A: 

can't you do some modifications in order to use ? where the #is used in navigate(), that would solve the problem if I did understand it well.

RC
The point of using # is to to use AJAX (it reloads only certain portion of the page) in order to navigate between pages. Since with AJAX, back button does not work and you can't bookmark stuff, # is used to enable functionality.
miki725
So the idea is that the crawler should see some PHP generated links (using ?) in order to be able to crawl them, and users with Javascript enabled, should navigate among # links which crawlers can't index since they don't understand Javascript.
miki725
http://googlewebmastercentral.blogspot.com/2007/11/spiders-view-of-web-20.html
miki725