繁体   English   中英

在ASP.NET的IIS中使用URL重写从页面中删除.aspx

[英]Removing .aspx from pages using URL Rewrite in iis in asp.net

我想从ASP.Net中的网页中删除.aspx。 我下载了URL重写模块,并将其安装到winserver 2008上,并且: http ://www.iis.net/downloads/microsoft/url-rewrite [^]

我是初学者,我尝试过

我还尝试使用IIS7和URL重写删除.aspx扩展名

但这没用。

例如,更改default.aspx ---> default如何执行此操作?


我收到错误404-找不到文件或目录。 当我使用此代码时:

<rewrite>
<rules>
    <rule name="Rewrite aspx" stopProcessing="true">
      <match url="^([a-z0-9/]+).aspx$" ignoreCase="true"/>
      <action type="Redirect" url="{R:1}"/>
    </rule>
</rules>

请F1F1F1F1F1

U can do this in your web.config file itself

 <system.web>

    <urlMappings enabled="true">

        <add url="~/marutisuzuki-Alto" mappedUrl="~/Carmodel.aspx?carname=Alto&amp;carid=6"/>
</urlMappings>
</system.web>

If you add this if any page with this "~/Carmodel.aspx?carname=Alto&amp;carid=6" is replaced by "~/marutisuzuki-Alto".

使用URL重写模块,可以在web.config(在system.webServer元素内部)中尝试以下操作:

<rewrite>
    <rules>
        <rule name="Rewrite aspx" stopProcessing="true">
          <match url="^([a-z0-9/]+).aspx$" ignoreCase="true"/>
          <action type="Redirect" url="{R:1}"/>
        </rule>
    </rules>
</rewrite>

我的网络配置:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
        <remove name="ChartImageHandler" />
        <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>
    <security>
        <authentication>
            <basicAuthentication enabled="false" />
            <windowsAuthentication enabled="false" />
        </authentication>
    </security>
    <rewrite>
        <rule name="Rewrite aspx" stopProcessing="true">
            <match url="^([a-z0-9/]+).aspx$" ignoreCase="true"/>
            <action type="Redirect" url="{R:1}"/>
        </rule>



    </rewrite>
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
        </system.webServer>
<appSettings>

    <add key="ChartImageHandler" value="storage=file;timeout=20;" />
</appSettings>
<system.web>


    <httpHandlers>
        <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
    </httpHandlers>
    <customErrors mode="On" defaultRedirect="ErrorPage" />
    <!-- 
        Set compilation debug="true" to insert debugging 
        symbols into the compiled page. Because this 
        affects performance, set this value to true only 
        during development.
    -->
    <compilation debug="true" targetFramework="4.0">
        <assemblies>
            <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </assemblies>
    </compilation>

    <authentication mode="Windows" />

    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
        <controls>
            <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </controls>
    </pages>
    <httpRuntime maxRequestLength="10480" />
    <identity impersonate="false" />

</system.web>

<!-- 
    The system.webServer section is required for running ASP.NET AJAX under Internet
    Information Services 7.0.  It is not necessary for previous version of IIS.
-->

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM