I'm searching for SEO ways for my ajax website for a while. I know there are several ways to handle that but i wonder if my solution will work.
So if i have index.html like that.
<header>
<a href="/otherpage" class="ajax-load">Link to other page</a>
</header>
Then check if it's not Google bot and replace href with ajax link.
var isGoogleBot = navigator.userAgent.toLowerCase().indexOf('googlebot') > 0;
//Check if it's not Google Bot
if( !isGoogleBot ) {
//Convert link to ajax link
$('.ajax-load').each(function(i,el){
var href = $(el).attr('href');
$(el).attr('href', '#' + href);
});
}
In "/otherpage" directory i'll create and index.php file contains:
<?php
include("../header.php");
include("content.php");
include("../footer.php");
?>
So, if it's a Google bot link won't change and bot will crawl http://example.com/otherpage (which is generated by php), and if it's a real user i will only load content.php to my wrapper through ajax without jump.
Does it work?