In IIS7 we no longer need to install other components, and the pseudo-static of the URL can be achieved by simple configuration in web.config. Here's how:
Add the following code to the configuration node of the web.config configuration file:
Code is as follows
<system.webServer> <rewrite> <rules> <rule name ="rulename"> <match url="newurl" ignoreCase="false" /> <action type="Rewrite" url="oriurl" appendQueryString="false" /> < ;/rule> </rules> </rewrite> </system.webServer>
where rule node is the rule for each rewrite, match node is pseudo-static; ignoreCase is ignored Case; action is the URL of the response, the real URL; appendQueryString is the parameter. When adding multiple rules, be aware that the name name should remain different.
The following directly gives the URL rewriting rules of this site, I believe everyone will know at a glance:
The code is as follows
<rewrite> <rules> <rule name="rule1"> <match url="articles/(S+).html" ignoreCase="true" /> <action type="Rewrite" url="articles/Default.aspx?SubClass={R:1} " appendQueryString="true" /> </rule> </rules> </rewrite>
Visible, if you use the $ character with IIS6, use {R in IIS7 : Number} instead of $ character. When it comes to multiple parameters, don't forget to replace the & symbol with &.
If you are iis6, you can refer to the following method to instantiate pseudo-static
We need to download the official URLRewriter.dll provided by Microsoft. After downloading, we will refer to some dll files in our project. Next, you need to do some simple configuration in web.config to implement url redirection.
First, find configSections in webconfig and add the given code in the following location:
The code is as follows
</sectionGroup> <section name="RewriterConfig" type="URLRewriter .Config.RewriterConfigSerializerSectionHandler, URLRewriter" /> </configSections>
Next, find httpHandlers and add the given code in the following location:
The code is as follows <httpHandlers> <add verb= "*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" /> <add verb="*" path="*.html" type="URLRewriter. RewriterFactoryHandler, URLRewriter" />
The code added above will redirect the url path of the .html and .aspx suffixes. Finally, we want to add a redirected rule to implement url redirection.
Code is as follows
</configSections> <RewriterConfig> <Rules> <RewriterRule> <LookFor>~/article/(S+)/(d{8})/(S+).html< /LookFor> <SendTo>~/article/default.aspx?Sub=$1&UrlName=$3</SendTo> </RewriterRule> </Rules> </RewriterConfig>
This is the rule of redirection. The above is an example of my own small station. Redirect domain/article/article type/release time/article name.html to domain/article/default.aspx?Sub=article type&UrlName=article name. I am not very familiar with the regularity, ^_^. If you are interested, you can learn, and finally don't forget to write the & symbol in &UrlName to & ,
As the weather gets hotter, many small and medium-sized companies see their data center cooling syst
Problem: The lack of .net2.0 and vc9 caused some software to be uninstalled. Phenomenon: Users canno
The first part of the basic environment configuration First, a brief introduction
First of all, you must establish a peer-to-peer LAN, and set the IP a
A case where the server security dog caused an ASP.NET website to run incorrectly
Server storage SAS hard disk technology
The most complete in history! Proxy server settings method highlights
WinHTTP Web Proxy Auto-Discovery Service service is stopped
Solution for MySQL service not starting properly (1053 error)
Nginx start, stop, restart, upgrade operation command collection
Wrong application w3wp.exe processing method
IIS reported that the script language VBScript.encode error solution was not found on the server
How does Win10 clear the most recently used files on the homepage interface
How to set up win7 system prohibits any software installation
Win8.1 how to remove the residual items of the control panel after uninstalling the program
Windows 10 Build 10056 and then exposed new maps Built-in multiple theme color scheme
How to use Win8's taskbar flexibly
What should I do if the win7 sound card driver is not fully displayed?
Win10 registry has no permission to open the solution
How to use YouTube mobile live broadcast Connect application live tutorial
Manage Active Directory Database (Compression/Mobile) for Windows Server 2008 R2