dq1230123 2015-08-24 15:55
浏览 68

让Googlebot以这种方式抓取我的Ajax网站?

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 livecharts wpf piechart 属性
    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
    • ¥20 易康econgnition精度验证
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置