代码之家  ›  专栏  ›  技术社区  ›  Abijith Ajayan

Prerender未检测到带有angularjs的IIS的令牌

  •  0
  • Abijith Ajayan  · 技术社区  · 6 年前

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
          <httpProtocol>
                <customHeaders>
                    <add name="X-Prerender-Token" value="MY TOKEN" />
                </customHeaders>
            </httpProtocol>
          <rewrite>
            <rules>
        <rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAny">
              <add input="{SERVER_PORT_SECURE}" pattern="^0$" />
            </conditions>
            <action type="Redirect" url="https://www.homes247.in/" redirectType="Permanent" />
        </rule>
    
        <rule name="Enforce canonical hostname" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" matchType="Pattern" pattern="^www\.homes247\.in$" ignoreCase="true" negate="true" />
          </conditions>
          <action type="Redirect" url="https://www.homes247.in/{R:1}" redirectType="Permanent" />
        </rule>
    
        <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|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator" />
                            <add input="{QUERY_STRING}" pattern="(.*)_escaped_fragment_(.*)" ignoreCase="false" />
                        </conditions>
                        <action type="Rewrite" url="https://service.prerender.io/https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
        </rule>
    
    
              <rule name="AngularJS Routes" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAll">
                  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                  <add input="{REQUEST_URI}" pattern="^/(cms)" negate="true" />
                  <add input="{REQUEST_URI}" pattern="^/(crm)" negate="true" />
                      </conditions>
                <action type="Rewrite" url="/" />
             </rule>
             
    </rules>
          </rewrite>
            <staticContent>
                <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
            </staticContent>
        </system.webServer>
    </configuration>

    我正在尝试SEO友好和社交媒体共享的目的。

    例如:

    <div><h1>{{Title}}</h1></div>
    

    0 回复  |  直到 6 年前
        1
  •  0
  •   Prerender.io    6 年前

    而不是:

    <httpProtocol>
        <customHeaders>
            <add name="X-Prerender-Token" value="MY TOKEN" />
        </customHeaders>
    </httpProtocol>
    

    您能在<规则>中尝试一下吗:

    <rule name="Prerender" stopProcessing="true">
        <serverVariables>
            <set name="HTTP_X_PRERENDER_TOKEN" value="MY TOKEN" />
        </serverVariables>
        ...
    

    您可能需要将HTTP_X_PRERENDER_令牌作为允许的服务器变量添加到您的IIS服务器中,以确保通过该令牌发送。我知道您可以在IIS用户界面中设置允许的服务器变量。