Prerender io giving 404 error

随声附和 提交于 2019-12-12 01:27:58

问题


I created an angulerjs web application and set the SEO tags for each pages like Angularjs website not indexing on google

My web application is hosted in IIS server. So I changed my web config file to configure as follows.

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="X-Prerender-Token" value="XXXXXXXXXXXXX" />
            </customHeaders>
        </httpProtocol>
        <rewrite>
            <rules>
                <!--# Only proxy the request to Prerender if it's a request for HTML-->
                <rule name="Prerender" stopProcessing="true">
                    <match url="^(?!.*?(\.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))(.*)" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny">
                        <add input="{HTTP_USER_AGENT}" pattern="baiduspider|facebookexternalhit|twitterbot" />
                        <add input="{QUERY_STRING}" pattern="_escaped_fragment_" ignoreCase="false" />
                    </conditions>
                    <action type="Rewrite" url="http://service.prerender.io/http://yourwebsite.com/{R:2}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration> 

I configure the web config with my own prerender token and logged in to Prerender.io and cached my website pages.

When I load http://www.mywebsite.com/?_escaped_fragment_= this link give me "404 - File or directory not found" error now.


回答1:


I could solve this problem by changing Action type Rewrite to Redirect as follows.

<action type="Redirect" url="http://service.prerender.io/http://yourwebsite.com/{R:2}" />

Edited

But action type Redirect will effect to social sharing of your web site. So keep it as Rewrite and install Application Request Routing to the IIS server and enable proxy.

This would help to someone :)



来源:https://stackoverflow.com/questions/29160320/prerender-io-giving-404-error

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