簡體   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