0

我有一個PHP的AJAX網站,提供網頁到我的用戶喜歡谷歌AJAX抓取失敗

http://www.example.com/ => this has all the individual page contents like listing 
    http://www.example.com/#!page1-uid => has page1 contents, uid is the unique mongoDB identifier for that page 
    http://www.example.com/#!page2-uid => has page2 contents, uid is the unique mongoDB identifier for that page 

我希望Google抓取我的網站的大約200多頁的索引所有,但他們都不是獲得索引

我幾乎遵循和理解谷歌AJAX爬行方法,但不知道我仍然失蹤的地方/什麼。

這裏是設置:

的.htaccess

RewriteCond %{HTTP_USER_AGENT} (googlebot|yahoo|bingbot|baiduspider) [NC] 
    RewriteCond %{QUERY_STRING} _escaped_fragment_=(.*)$ 
    RewriteRule ^(.*)$ botIndex.php?QSA=%1 [QSA,L] 

botIndex.php

$var1 = $_REQUEST['QSA']; 
checks if QSA is set, if so, serves the individual page1/page2 
else gives out the default home page that has the listing of all the page links 

當我測試使用GWT( 「取爲谷歌」),在這裏是我觀察到的模式

a) www.example.com/ => it gets redirected to botIndex.php and returns me all the links (default view) just as expected 
    b) www.example.com/#!page1-uid => redirects to the botIndex.php and returns me all the links but ideally it should return the actual page content instead of the home page contents (not sure GWT has the ability to ask for _escaped_fragment_ to mimic googlebot) 
    c) www.example.com/?_escaped_fragement_ => GWT returns "Not found" error 

通過在botIndex.php中添加少量回顯,我懷疑上述任何一個都不會顯示「_escaped_fragment_」被捕獲 因此我的腳本botIndex.php沒有獲得QUERY_STRING(QSA)的值,爲頁面1 /頁面2個別頁面提供服務,而不是總是 默認爲顯示所有頁面列表的主頁。

我測試的URL的直接botIndex.php像

a) http://www.example.com/botIndex.php?_escaped_fragment_=QSA= (returns all the links) 
    b) http://www.example.com/botIndex.php?_escaped_fragment_=QSA=page1-uid (returns the actual page details) 

我是什麼人仍下落不明?

我堅信.htaccess的問題不可能將QSA傳遞給我的腳本。

請建議。

更新:我仍然卡住。任何人都可以幫助我一些指針?

回答

0

顯然,您在重寫期間保留GET參數時遇到問題。嘗試調試你的.htaccess指令。

另一個選擇是爲您的php應用程序創建一個入口點,就像所有現代框架一樣。並在您的PHP應用程序中實現所有邏輯(爲機器人提供html內容)。

+0

嗨@alex,謝謝。任何指向什麼框架的指針?我一般不會使用框架,不太熟悉。 – Param

+0

熟悉現代php開發工作流程的好處是laravel框架:https://github.com/laravel/laravel但是現在你需要的是https://github.com/laravel/laravel/blob/master/public/ .htaccess部分處理前端控制器。使用這種技術,您可以使用您的php應用程序處理所有http請求 – Alex