Ad

How To Benefit Of Prerender.io Services If My Apache Server Doesn't Allow A Proxy

- 1 answer

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?

Ad

Answer

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

Ad
source: stackoverflow.com
Ad