3

所有,当我部署一个网站时,我遇到了一个问题。rewrite我发现web.config 中有一个名为的元素 。

<rewrite>
        <rules>
            <!-- below rule will abort api request when the request to pattern "apis/v.*" is of "http" method-->
            <rule name="AbortApiHTTPRequest">
                <!-- Note:
                        the below pattern is assumed that all apis conain prefix "apis/v", e.g. apis/v3/aaauth
                        if there are some exceptions for the assumption, below pattern needs to be updated.
                -->
                <match url="^apis/v.*$" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                </conditions>
                <action type="AbortRequest" />
            </rule>

            <!-- below rule will redirect all non-https requests except for above requests to https request.-->
            <rule name="RedirectToHTTPS" stopProcessing="true">
                <match url="^.*$" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                </conditions>
                <action type="Redirect" url="https://{SERVER_NAME}/{R:0}" redirectType="SeeOther" />
            </rule>
        </rules>
    </rewrite>

当我删除元素一切正常时,网站运行良好。否则我得到一个错误说。

HTTP 错误 500.19 - 内部服务器错误 无法访问请求的页面,因为该页面的相关配置数据无效。

在我做了一些研究之后,我发现这个问题在谈论它。我不确定这是否是问题的原因。似乎它只是 .xml 的 xml 语法验证Visual studio。在 IIS 7 中部署网站真的很重要吗?

无论如何,我也按照帖子的说明进行操作,但我未能使其正常工作。即使我cmd以管理员身份运行。错误如下所述。

无法打开文件 Xml\Schemas\DotNetConfig.xsd。确保脚本在提升的命令提示符下运行。

如果我有足够的特权来运行cscript命令,我会徘徊吗?谢谢。

更多的

如果我在 Visual Studio 中运行项目Asp.net development server,它可以正常工作而不会出现任何错误。但是,如果我将项目发布到计算机中的 IIS。它不起作用。

4

1 回答 1

3

IIS 的 URLRewrite 模块使用 rewrite 指令。

如果未安装该模块,您将收到与上述类似的错误。如果您需要 URLRewriting,您可以安装该模块 - 或者 - 注释掉整个<rewrite>部分。

于 2013-08-15T07:04:31.837 回答