내각 앱 생성 페이지가 HashBangs를 사용하지 않고 Google에서 완벽하게 크롤링하려고 시도합니다. #!
그래서 함께 pushstate URL을 생성 : Google 크롤러가 미리 렌더링 된 각도 생성 페이지가 표시되지 않습니다.
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
앱의 설정에 추가하고, HTML 헤더에
<base href="/hockey-att/">
<meta name="fragment" content="!">
.
그리고 나는 .htaccess
이 있습니다
RewriteEngine on
RewriteBase /1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ #/$1 [L]
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "prerendertoken"
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_proxy_http.c>
RewriteEngine On RewriteCond %{HTTP_USER_AGENT} baiduspider|googlebot|googlebot-mobile|bingbot|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_=(\%2F|/)_(._)
# Only proxy the request to Prerender if it's a request for HTML
RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/http://%{HTTP_HOST}/$2 [P,L]
</IfModule>
</IfModule>
나는 하위 폴더 1
에서 응용 프로그램 토큰 prerender.io 설정의 .htaccess에서 RequestHeader set X-Prerender-Token
섹션이 있습니다.
새 URL이있는 앱은 완벽하게 작동하며 prerender.io를 사용하여 페이지를 렌더링합니다. 페이지는 사전 렌더링되어 있으며 문제없이 액세스 할 수 있습니다. http://service.prerender.io/ {http://myurl.com/page}
문제는 Google 크롤러가 미리 렌더링 된 페이지에 액세스하지 않는다는 것입니다. 가져온 URL에 ?_escaped_fragment_=
을 추가하거나 삭제하지 않고 Search Console의 Fetch as Google 기능을 통해 검색하려고 시도했습니다. 그러나 그것은 여전히 원점에 각도 지시어가있는 원시 페이지를 얻습니다.
.htaccess에서 뭔가 빠졌다고 생각하지만, 무엇을 모르겠습니다.
각도 상태에 ui-router를 사용합니다.
'#'을 제거하면 브라우저에서'http : // myurl.com/1/state' URL을 여는 것처럼 페이지에 직접 액세스 할 수 없으므로 404 오류가 발생합니다. 이 경우 Fetch as Google에서 나를 찾을 수 없음 오류를 표시합니다. – neptune
index.html은 어디에서 제공됩니까? 그래서 그것이 404ing 인 것 같습니다. 모든 요청에 대해 index.html을 제공하려면 Prerender config 다음에 몇 가지 코드가 필요합니다. –
http://myurl.com/1/index.html에서 index.html을 가지고 있으며 URL을 푸시 스테이트 URL로 구현하기 전에 http://myurl.com/1/#/home URL을 사용했습니다. [이것은] (http://sigmagfx.com/1) 내가 작업하고있는 사이트입니다. 나는 myroot url에서 Pico CMS 사이트를 가지고 있다고 언급 할 가치가 있다고 생각한다. – neptune