If urlrewriter. config. rewriterconfigserializersectionhandler is used, it is troublesome to implement URL with or without a Suffix in urlrewriter because of style and image Path Problems.
Later, intelligencia. urlrewriter was selected for implementation, which is much more convenient than the former.
Steps:
1. Download intelligencia. urlrewriter
2. Reference in the project
3. webconfig Configuration:
<configSections>
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<rewriter>
<rewrite url="^/404.html/?$" to="/404.aspx" processing="stop" />
<rewrite url="^/?$" to="/Default.aspx" processing="stop" />
</rewriter>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
</modules>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
4,How to configure intelligencia. urlrewriter in iis7 and 7.5:
In Vista, win7, and server2008, the IIS version is V7 +, and the IIS6 rewrite configuration is invalid in iis7. Because IIS6 can only be allocated to ASP in requests. iis7 can execute an httpmodule anywhere in the IIS request pipeline, and iis7 has to reset the access permissions for files or folders.
If it is an iis7.0/7.5 running environment, add this configuration
<System. webserver>
<Modules>
<! -- Your custom IIS rewrite module operation -->
<Add name = "urlrewriter" type = "intelligencia. urlrewriter. rewriterhttpmodule"/>
</Modules>
</System. webserver>
5. configurations on servers 2003 and:
IIS-website-properties-home directory-configuration-Wildcard application ing (execution sequence)-insert-browse to Asp.net _ ISAPI. DLL-"determine whether the file exists and do not select-" OK"
Asp.net _ ISAPI. DLL (Address: C: \ WINDOWS \ Microsoft. net \ framework \ v2.0.50727 \ aspnet_isapi.dll), it is worth noting that if you have added "application expansion" before, remember to delete it.
Make sure that the preceding steps can be accessed either on iis7 or on the windowserver server.
Supplement: (from http://www.cnblogs.com/Fred_Xu/archive/2009/11/22/intelligencia-urlrewriter-resource.html)
Reference blog: http://devtalk.dk/2007/03/19/Wildcard+Mapping+And+URL+Rewriting+On+IIS7.aspx [recommended]
Http://aspalliance.com/1234_TipTrick_Url_Rewriting_with_ASPNET.3
Http://www.improve.dk/blog/2006/12/11/making-url-rewriting-on-iis7-work-like-iis6
4. Example of rewrite HTML rules:
(1)
Note:
When wildcard ing is used or ASP. NET is used to process all HTTP requests, the default document mechanism of IIS loses its role. The following code is used to re-implement the default document:
<Rewrite url = "^ (.*)/(\?. + )? $ "To =" $1/default. aspx $2 "/> NOTE: When" Processing = "restart" is used, the rewrite engine will execute all rewrite rules from the beginning. In this case, the rewrite engine should focus on "/default. processing of the aspx string.
If you need to support multiple default documents at the same time, you need to modify the above Code:
<If url = "^ (.*)/(\?. + )? $ ">
<Rewrite exists = "$1/default. aspx" to = "$1/default. aspx $2"/>
<Rewrite exists = "$1/index. aspx" to = "$1/index. aspx $2"/>
<Rewrite exists = "$1/index.html" to = "$1/index.html $2"/>
</If> when editing the preceding rule code, make sure that the file exists.
When using a wildcard to process all HTTP requests using asp.net, you will find that files such as .gifini.css cannot be accessed normally, because ASP. NET intercepts the processing of these file types. The correction method is as follows:
<Rewrite
Url = "^ (/. + (\. gif | \. PNG | \. jpg | \. ICO | \. CSS | \. JS )(\?. + )?) $"
To = "$1" Processing = "stop"/> two special regular expression characters are "^" and "$" (not required ), "^" indicates the beginning of the URL, and "$" indicates the end of the URL. These two symbols allow you to more accurately control the rewrite action to ensure that the URL that the program matches is exactly what you want to process.
"~ /"Indicates the virtual root directory where the current website application program runs. This is especially useful when you install the website application in a virtual directory (or non-root directory, you do not need to rewrite any code to replace your virtual root path.
Pattern matching is particularly useful when processing query strings (querystrings). This allows you to remove URLs that are similar to "? Id = 3 "code segment, which is very useful and allows you to easily implement pseudo-static.
The following lists two rewrite rules that we think are very distinctive:
(1) When the target URL does not contain a custom query string:
<Rewrite url = "^ ~ /Mypage (\?. + )? $ "To = "~ /Default. aspx $1 "/> at this time," $1 "Matches (\?. + )?, That is, all query strings.
(2) When the target URL contains a custom query string:
<Rewrite url = "^ ~ /Mypage (\? (. + ))? $"
To = "~ /Default. aspx? Page = mypage & $2 "/> note that" & amp; "must be used to replace" & ", which is required by the XML Document Syntax.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/bl_song/archive/2009/11/03/4761343.aspx
(2)
<Rewriter>
<Rewrite url = "~ /Default.html $ "to = "~ /Default. aspx "Processing =" stop "/>
<Rewrtie url = "^ ~ /(\ D +)/(\ d00000000.html "to = "~ /Default. aspx? Id = $1 & amp; artcleid = $2 "/> // multiple parameters
<Rewrite url = "~ /News_(%0-9%%%%.html $ "to = "~ /Article/articleshow. aspx? Id = $1 "Processing =" stop "/>
<Rewrite url = "~ /Result _ ([0-9] +). aspx $ "to = "~ /Job/Company/result. aspx? Cid = $1 "Processing =" stop "/>
<Rewrite url = "~ /Company_(%0-9%%%%.html $ "to = "~ /Company/$1/index.html "Processing =" stop "/>
<Rewrite url = "~ /Resume/(%0-9%%%%_(%0-9%%%%%%.html $ "to = "~ /Resume/$1/resume_20.2.html "Processing =" stop "/>
<Rewrite url = "~ /(%0-9%%%%_(%0-9%%%%%%.html $ "to = "~ /Company/$1/job_20.2.html "Processing =" stop "/>
<Rewrite url = "~ /Job_(%0-9%%%%.html $ "to = "~ /Company/$1/jobs_20.1.html "Processing =" stop "/>
<Rewrite url = "~ /News_l(1_0-91_1_1_1__1.html $ "to = "~ /Company/$1/$1_news.html "Processing =" stop "/>
<Rewrite url = "~ /News_(%0-9%%%%%%v(%0-9%%%%%%.html $ "to = "~ /Company/$1/n_00002.html "Processing =" stop "/>
<Rewrite url = "~ /Contact_(%0-9%%%%.html $ "to = "~ /Company/$1/contact.html "Processing =" stop "/>
<Rewrite url = "~ /A _ (. +) _ (. +). aspx $ "to = "~ /A. aspx? Id = $1 & amp; id1 = $2 "Processing =" stop "/> // multiple parameters
</Rewriter>
Copy code
5. Blog garden resource sorting:
Jeffrey Zhao's blog:
Rewrite URL (1): IIS and ASP. NET
Remention URL rewrite (2): use existing components for URL rewrite
Repeat URL rewrite (3): Keep the PostBack address after URL rewrite // This article is of the greatest help to me and must be used in actual projects.
Repeat URL rewrite (4): details and features of different levels of URL rewrite
6. intelligencia. urlrewriter conflicts with fck Editor:
In the iis7/7.5 environment, we recommend that you use the integration mode instead of the Classic mode. Otherwise, the urlrewriter and fck Editor may conflict with each other, resulting in the failure to execute the URL on the fck editor page.