2016-08-09 44 views
0

ASP.Net URL重寫模塊我想要做的URL重寫與Intelligencia.UrlRewriter.RewriterHttpModule在ASP.Net這是我繼的System.Web在web.config中的Javascript CSS圖像不顯示

> <configSections> 
>  <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, 
> Intelligencia.UrlRewriter" /> </configSections> 

配置

<httpModules> 
     <add type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" name="UrlRewriter" /> 
    </httpModules> 

我想follwoing類型的URL

site.com/home site.com/contact site.com/info site.com/page/innerpage此 site.com/in/info

我寫下面的規則分別

<system.webServer>  
    <rewrite> 
     <rules> 
     <rule name="RewriteUserFriendlyURL1" stopProcessing="true"> 
      <match url="^Home$" /> 
      <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="\.aspx$" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="Default.aspx" /> 
     </rule> 
     <rule name="RewriteUserFriendlyURL2" stopProcessing="true"> 
      <match url="^contact$" /> 
      <conditions> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="contact.aspx" /> 
     </rule> 
     <rule name="RewriteUserFriendlyURL3" 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="info.aspx?keyword={R:1}" /> 
     </rule> 
     <rule name="Rewrite to page.aspx"> 
      <match url="^pages/([^/]+)" /> 
      <action type="Rewrite" url="page.aspx?page={R:1}" /> 
     </rule> 
     <rule name="Rewrite to info.aspx"> 
      <match url="([_0-9a-z-]+)/([_0-9a-z-]+)" /> 
      <action type="Rewrite" url="info.aspx?keyword2={R:1}&amp;keyword={R:2}" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
    <rewriter> 

    </rewriter> 

一切工作正常,但如果最後使用規則我曾經得到和CSS/JavaScript停止工作,所有我嘗試了許多解決方案來解決CSS/JavaScript /圖像規則暗示,但沒有奏效。

site.com/in/info

<rule name="Rewrite to info.aspx"> 
       <match url="([_0-9a-z-]+)/([_0-9a-z-]+)" /> 
       <action type="Rewrite" url="info.aspx?keyword2={R:1}&amp;keyword={R:2}" /> 
      </rule> 

回答

0

嘗試<match url="^([_0-9a-z-]+)/([_0-9a-z-]+)$" />

而且我通常會添加一個角色重寫每一個網頁,讓你不會在URL需要的.aspx 。因此,您可以編寫www.domain.com/home而不是www.domain.com/home.aspx,www.domain.com/subpage/contact而不是www.domain.com/subpage/contact.aspx等。

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

我做了更改,但沒有更改 – Yagnesh