I am a beginner. I dare not talk about the specific implementation principle. I just wrote the usage method for your reference. (In this example, I used the HTTP module to rewrite the URL)
1. Rewrite showplay1.aspx to showplay. aspx? Vid = 1:
1 download the DLL and put it under the bin directory of the website and directory:
Http://www.ckcom.cn/urlrewriter.rar
2. Add the following nodes in <system. Web> and </system. Web> of Web. config:
<Httpmodules>
<Add type = "urlrewriter. modulerewriter, urlrewriter" name = "modulerewriter"/>
</Httpmodules>
3. Add the following nodes in <configuration> and </configuration> of Web. config:
<Configsections>
<Section name = "rewriterconfig" type = "urlrewriter. config. rewriterconfigserializersectionhandler, urlrewriter"/>
</Configsections>
<Rewriterconfig>
<Rules>
<! -- Rewrite Rules -->
<Rewriterrule>
<! -- URL format to be implemented -->
<Lookfor> ~ /Showplay-(\ D {1, 4}) \. aspx </lookfor>
<! -- Real URL address. $1. $2, $3... $ n indicates the nth expression of Regular Expression matching. -->
<Sendto> ~ /Showplay. aspx? Vid = $1 </sendto>
</Rewriterrule>
</Rules>
</Rewriterconfig>
4. Adding a connection like a ShowPlay-1.aspx in the web page will be overwritten to showplay. asp? Vid = 1
2. Implement http://www.ckcom.cn/showplay1/rewrite to http://www.ckcom.cn/showplay.aspx? Vid = 1
The method is the same as step 1. Additionally, you need to ensure that default. aspx is added to the default Main Document of the website. The showplay1 directory must exist in the website directory and the default. aspx directory must exist in the showplay1 directory.
The corresponding rewrite rule should be changed
<! -- URL format to be implemented -->
<Lookfor> ~ /Showplay-(\ D {1, 4})/Default \. aspx </lookfor>
<! -- Real URL address. $1. $2, $3... $ n indicates the nth expression of Regular Expression matching. -->
<Sendto> ~ /Showplay. aspx? Vid = $1 </sendto>
Note the following when using this method:
1. You cannot use Windows to authenticate user permissions. Use Form for authentication. In web. config, configure it as: <Authentication mode = "forms"/>
2. The path obtained using request. servervariables ["script_name"] is still: showplay. asp? Vid = 1
3. If the address to be rewritten is sent back, the address to be overwritten will be showplay. asp? Vid = 1
4. The suffix name must be. aspx. If it is another custom suffix name, for example,. net, map. Net to aspnet_isapi.dll in IIS so that. Net requests can
To the Asp.net engine.
The level is limited until now. For detailed principles and solutions, see:
Http://www.microsoft.com/china/msdn/library/webservices/asp.net/URLRewriting.mspx? PF = true