0

私はAngularjs Webアプリケーションを作成し、Angularjs WebサイトがGoogleにインデックスされていないなど、各ページにSEOタグを設定しました

私の Web アプリケーションは IIS サーバーでホストされています。そのため、Web構成ファイルを次のように構成するように変更しました。

<?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> 

独自の prerender トークンを使用して Web 構成を構成し、Prerender.ioにログインして Web サイト ページをキャッシュしました。

http://www.mywebsite.com/?_escaped_fragment_=をロードすると、このリンクから「404 - ファイルまたはディレクトリが見つかりません」というエラーが表示されます。

4

1 に答える 1

1

次のように Action type Rewrite を Redirect に変更することで、この問題を解決できました。

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

編集済み

ただし、アクション タイプのリダイレクトは、Web サイトのソーシャル共有に影響します。そのため、書き換えのままにし、Application Request Routing を IIS サーバーにインストールして、プロキシを有効にします。

これは誰かに役立つでしょう:)

于 2015-07-17T11:34:53.207 に答える