2017-05-13 16 views
2

情報:私は自分のサーバー上で正常に事前レンダリング(https://github.com/prerender/prerender)をインストールした事前レンダリング+ AngularJS - クローラのタイムアウト設定について

、Ubuntuの16

これは書き換えて、私の.htaccessですクローラが検出されたときにプレレンダリングするURL。例:http://www.example.nl/63/Merryhttp://example.nl:3000/http://www.example.nl/63/Merry

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 

RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|redditbot|slackbot|msnbot|googlebot|duckduckbot|bingbot|rogerbot|linkedinbot|embedly|flipboard|tumblr|bitlybot|SkypeUriPreview|nuzzel|Discordbot|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR] 
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=$ 
RewriteRule ^(.*)$ http://example.nl:3000/http://www.example.nl/$1? [R=301,L] 
#RewriteRule ^(.*)$ http://art.example.net/$1? [R=301,L] 

RewriteRule ^(.*)/(.*)$ /#$1/$2 [NC,L] 

問題になる:事前レンダリングを使用するとき

メタデータは、Skype、Redditに、Twitterでロードされていません。古いPHPウェブサイトのURLを書き直す:http://art.example.net(現在htaccessにコメントされています)が動作します。 PHPとAngularのウェブサイトにあるすべてのメタタグは同じであるため、問題解決の原因としては事前解決者が考えられます。事前レンダリングを使用した:(http://example.nl/63/Merry URLを使用してhttps://cards-dev.twitter.com/validator):Twitterから

エラー例

ERROR: Failed to fetch page due to: HttpConnectionTimeout 
WARN: this card is redirected to http://example.nl:3000/http://www.example.nl/63/Merry 

のTwitter(メインURL使用:http://example.nl/63/Merry)art.example.netにリダイレクト

INFO: Page fetched successfully 
INFO: 19 metatags were found 
INFO: twitter:card = summary_large_image tag found 
INFO: Card loaded successfully 
WARN: this card is redirected to http://art.example.net/63/Merry 

をPHPバージョンを使用すると、すべてのメタデータがロードされます。

今後、私はPHPウェブサイトを完全に削除したいので、プレレンダリングを使用するのが大好きです。 PrerenderはDiscordとPostman(変更されたUser Agentヘッダー付き)で動作します。なぜ私はそれが他のエージェントにとってうまくいかないのか分かりません。

答えて

1

書き換えルールは、リダイレクトではなくプロキシである必要があります。プリレンダーサーバーにリダイレクトすると、検索結果からプリレンダーサーバーにユーザーを直接送信するようにGoogleに指示するなど、あらゆる種類の問題が発生します(これは本当に悪いことです)。

書き換えルールの一部は次のようになります。

RewriteRule ^(.*)$ http://example.nl:3000/http://www.example.nl/$1? [P,L] 
0

ソリューション:

Twitterや他のクローラは、ドットとを扱うことができない「:」URLインチしたがって、単純なIPアドレスとポート番号は許可されません。私のサブドメインApacheのバーチャルホスト

のNode.jsアプリケーションにリダイレクトする問題を修正するには

、あなたがサブドメインを作成することができ、:

からの回答と一緒に
<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName prerender.example.net 
    ServerAlias prerender.example.net 
    ProxyPass/http://localhost:3000/ connectiontimeout=5 timeout=30 
</VirtualHost> 

https://serverfault.com/questions/497856/using-an-apache-virtualhost-to-access-a-node-js-instance-on-the-same-server

私はそれを働かせるように管理しました。

URLは既に貼り付けられているため、プロキシとリダイレクトはソーシャルメディアクローラにとって重要ではありませんが、プロキシタグを使用することをお勧めします。

関連する問題