我是一個n00b這個東西,我想爲prerender.io設置一個測試環境。這裏 我已經下載預渲染:https://github.com/prerender/prerender.git和我從命令行運行此:angularJS,prerender.io和ZF2:本地測試返回304訪問被禁止
$ npm install
$ node server.js
我讀到這裏的文檔:https://github.com/zf-fr/zfr-prerender
相反的:
return array(
'zfr_prerender' => array(
'prerender_url' => 'http://myprerenderservice.com'
)
);
我這樣做:
return array(
'zfr_prerender' => array(
'prerender_url' => 'http://localhost'
)
);
這是我的一個gular路由器:
var ListerApp = angular.module('ListerApp',[
'ListerAppFilters',
'sharedFactoryApp',
'sharedServiceApp',
'ListerAppController',
'infinite-scroll',
'angular-inview',
'ngRoute',
'itemsReady'
]);
ListerApp.config(['$routeProvider', '$httpProvider', '$locationProvider', function($routeProvider, $httpProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
$routeProvider
.when('/list/:page?',
{
templateUrl : '/assets/services/partials/list.html',
controller : 'ListerCtrl',
reloadOnSearch : false,
js : ['/assets/min/shoplist_js.min.js', '/assets/min/bootstrap-typeahead.min.js'],
resolve : {
sharedServiceAppData: function($sharedData){
return $sharedData.promise();
}
}
}
)
.when('/detail/:id?',
{
templateUrl: '/assets/services/partials/detail.html',
controller: 'DetailCtrl',
css : ['/assets/min/star-rating.min.css'],
resolve : {
sharedServiceAppData: function($sharedData){
return $sharedData.promise();
}
}
}
).otherwise({ redirectTo: '/list/1' });
}]);
該網址工作正常:http://localhost/shop/api/list
此URL返回 「禁止接入!」:http://localhost/shop/api/list?_escaped_fragment_=/list
error.log中contrains:
[core:error] [pid 5952:tid 1864] (20024)The given path is misformatted or contained invalid characters: [client ::1:50262] AH00127: Cannot map GET /http://localhost/shop/api/list?_escaped_fragment_=/list HTTP/1.1 to file
我的.htaccess file:
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
API網址目前不是真正的API。我已經嘗試了escaped_fragment鍵,但目前還沒有運氣。控制檯不會輸出任何東西... – poashoas 2014-10-29 10:44:51
這樣的聲音是一個nginx問題,如果它甚至沒有通過Prerender服務器。 – 2014-10-30 13:23:58
我一直沒有注意,當我啓動節點server.js它輸出:服務器端口3000上運行。所以當我這樣做:'prerender_url'=>'http:// localhost:3000/public/assets /服務/預渲染「控制檯返回」有200「等。現在我必須瞭解如何通過PHP訪問呈現的shizzle。我使用https://github.com/zf-fr/zfr-prerender,文檔並沒有告訴我如何檢索內容,它說:「從緩存中檢查是否已經有內容」 – poashoas 2014-10-30 14:50:29