How to benefit of prerender.io services if my Apache server doesn't allow a proxy

若如初见. 提交于 2019-12-13 02:54:40

问题


Having an Angular app, I want to benefit of an HTML prerendering for Search engines bots.

Here's my .htaccess configuration:

<IfModule mod_headers.c>
    RequestHeader set X-Prerender-Token "My_Token"
</IfModule>

    <IfModule mod_rewrite.c>
        Options +FollowSymlinks
        RewriteEngine on

                <IfModule mod_proxy_http.c>
                    RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
                   RewriteCond %{QUERY_STRING} _escaped_fragment_

            # 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://example.com/$2 [P,L]
               </IfModule>


                # Don't rewrite files or directories
                RewriteCond %{REQUEST_FILENAME} -f [OR]
                RewriteCond %{REQUEST_FILENAME} -d
                RewriteRule ^ - [L]

                # Rewrite everything else to index.html to allow html5 state links
                RewriteRule ^ index.html [L]
    </IfModule>

My issue is that the P flag involving proxy causes a 403 error:
"You don't have permission to access /"
when I run the following command:
curl http://example.com?_escaped_fragment_=

I don't own a dedicated server but an external shared Apache server. I contacted the support of this server instance and they argue that proxy are forbidden on shared instances, resulting in an error 403.

Is there any workaround to to benefit of prerender.io with Apache and .htaccess configuration without switching to a dedicated Apache Server?

Is the proxy flag mandatory?


回答1:


The proxy flag is mandatory because a redirect would incorrectly tell the crawlers to send your users to the redirected site instead.



来源:https://stackoverflow.com/questions/35224988/how-to-benefit-of-prerender-io-services-if-my-apache-server-doesnt-allow-a-prox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!