URL 重写 - web.config 错误 [英] URL rewrite - web.config error

查看:27
本文介绍了URL 重写 - web.config 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 .aspx 页面时出现以下错误.

错误代码0x8007000d无法读取配置部分重写",因为它缺少部分声明

我有一个简单的 v.aspx 页面,其中包含以下代码:

Response.Write(Request("q"))

我的托管服务器作为 IIS 7 安装并启用了 URL 重写功能(这就是他们声称的)

我的 web.config 文件在以下几行:

注意:节点下面有蓝色波浪线

<规则><规则名称="RewriteUserFriendlyURL1" stopProcessing="true"><match url="^([^/]+)/?$"/><条件><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/></条件><action type="Rewrite" url="v.aspx?q={R:1}"/></规则></规则></rewrite>

我已经搜索过stackoverflow,但没有找到解决方案.

可能有人找到了解决方案.

TIA

解决方案

确保您的 包含在 中; 部分.

<预><代码><配置><system.webServer><重写><规则><规则名称="RewriteUserFriendlyURL1" stopProcessing="true"><match url="^([^/]+)/?$"/><条件><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/></条件><action type="Rewrite" url="v.aspx?q={R:1}"/></规则></规则></rewrite></system.webServer></配置>

I am getting the following error when i run my .aspx page.

Error Code0x8007000d The configuration section 'rewrite' cannot be read because it is missing a section declaration

I have a simple v.aspx page which has the following code:

Response.Write(Request("q"))

My hosting server as IIS 7 installed with URL rewrite feature enabled (that's what they claim)

My web.config file has the following lines under :

Note: The node has blue squiggly lines under it

<rewrite>
      <rules>
        <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
          <match url="^([^/]+)/?$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="v.aspx?q={R:1}" />
        </rule>
      </rules>
    </rewrite>

I have searched stackoverflow but did not find a solution.

May be someone found a solution.

TIA

解决方案

Make sure your <rewrite> is enclosed in the <system.webServer></system.webServer> section.

<configuration>
   <system.webServer>
       <rewrite>
          <rules>
             <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
             <match url="^([^/]+)/?$" />
             <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="v.aspx?q={R:1}" />
             </rule>
          </rules>
        </rewrite>
    </system.webServer>
</configuration>

这篇关于URL 重写 - web.config 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆