0

我像这样使用我的 Web.config

<?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 友好和社交媒体共享为目的。

出于 SEO 目的,我还希望在页面视图源中呈现数据。我在这部分为页面视图源而苦苦挣扎。

例如:

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

我希望标题内容也在页面视图源中。如何在 angularjs 的视图源中呈现页面。

4

1 回答 1

0

代替:

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

你能在 <rule> 里面试试这个:

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

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

于 2019-03-10T17:42:51.367 回答