【问题标题】:Getting a URL Rewrite error 500 when prerendering预呈现时出现 URL 重写错误 500
【发布时间】:2022-09-23 16:28:26
【问题描述】:

也许有人可以帮助我。 我的 web.config 中有两条规则,一条用于pre-render,一条用于 Vue。 我把它们叠成这样:

<rules>
    <rule name=\"prerender.io\" stopProcessing=\"true\">
        <match url=\"(\\.js|\\.json|\\.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|\\.svg)\" negate=\"true\" />
        <conditions logicalGrouping=\"MatchAny\">
            <add input=\"{HTTP_USER_AGENT}\" pattern=\"googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\\ link\\ preview|showyoubot|outbrain|pinterest\\/0\\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp\" />
            <add input=\"{QUERY_STRING}\" pattern=\"_escaped_fragment_\" />
        </conditions>
        <serverVariables>
            <set name=\"HTTP_X_PRERENDER_TOKEN\" value=\"<removed>\" />
        </serverVariables>
        <action type=\"Rewrite\" url=\"https://service.prerender.io/https://{HTTP_HOST}{REQUEST_URI}\" appendQueryString=\"false\" logRewrittenUrl=\"true\" />
    </rule>

    <rule name=\"Vue\" stopProcessing=\"true\">
        <match url=\".*\" />
        <conditions logicalGrouping=\"MatchAll\">
            <add input=\"{REQUEST_URI}\" pattern=\"^/api/.*\" negate=\"true\" />
            <add input=\"{REQUEST_FILENAME}\" matchType=\"IsFile\" negate=\"true\" />
            <add input=\"{REQUEST_FILENAME}\" matchType=\"IsDirectory\" negate=\"true\" />
        </conditions>
        <action type=\"Rewrite\" url=\"/\" />
    </rule>
</rules>

问题是,当 googlebot 尝试访问我的网站时,大多数时候它会返回 URL 重写错误 500。如果我从 prerender 规则中删除 googlebot,它将停止抛出重写错误,这让我相信这个问题符合这条规则,但他们的支持团队告诉我不是。

谁能看到我的规则有任何明显的问题?或者知道我错过了什么?

  • 错误日志中是否有任何消息?通常 500 错误在那里有更多的调试信息。我在想添加 Googlebot 会使模式太长或其他什么。

标签: url-rewriting googlebot prerender


【解决方案1】:

事实证明这是由于 ARR 代理未打开。 因为我在 Azure 上托管,所以它必须创建一个名为的新文件应用程序主机.xdt并添加:

<?xml version="1.0"?>  
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  
    <system.webServer>  
        <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false"  
        reverseRewriteHostInResponseHeaders="false" />
        <rewrite>
            <allowedServerVariables>
                <add name="HTTP_X_PRERENDER_TOKEN" xdt:Transform="InsertIfMissing" />
            </allowedServerVariables>
        </rewrite>  
    </system.webServer>  
</configuration>

如果你使用 IIS,你可以点击这个链接:

https://learn.microsoft.com/en-us/iis/extensions/configuring-application-request-routing-arr/creating-a-forward-proxy-using-application-request-routing

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-10
    • 2012-05-26
    • 2020-10-05
    • 2022-10-01
    • 2014-06-02
    • 1970-01-01
    • 2011-12-28
    相关资源
    最近更新 更多