Pseudo-static web.config common rule writing and parameter introduction.
Example 1:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="规则 1" stopProcessing="true">
<match url="^includes/(.*)" />
<action type="Rewrite" url="includes\/{R:1}" />
</rule>
<rule name="规则 2" stopProcessing="true">
<match url="^(blog)/includes/(.*)" />
<action type="Rewrite" url="{R:1}/includes\/{R:2}" />
</rule>
<rule name="规则 3" stopProcessing="true">
<match url="^(blog)/(.*).html(.*)" />
<action type="Rewrite" url="{R:1}/index.php\/{R:2}.html{R:3}" />
</rule>
<rule name="规则 4" stopProcessing="true">
<match url="^(.*).html(.*)" />
<action type="Rewrite" url="index.php\/{R:1}.html{R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Example 2:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1">
<match url="list-([0-9]+)\.html" ignoreCase="false"/>
<action type="Rewrite" url="plus/list.php?tid={R:1}" appendQueryString="false"/>
</rule>
<rule name="Imported Rule 2">
<match url="list-([0-9]+)-([0-9]+)-([0-9]+)\.html" ignoreCase="false"/>
<action type="Rewrite" url="plus/list.php?tid={R:1}&TotalResult={R:2}&PageNo={R:3}" appendQueryString="false"/>
</rule>
<rule name="Imported Rule 3">
<match url="view-([0-9]+)-([0-9]+)\.html" ignoreCase="false"/>
<action type="Rewrite" url="plus/view.php?arcID={R:1}&pageno={R:2}" appendQueryString="false"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Example 3:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="portal_topic">
<match url="^(.*/)*topic-(.+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/portal.php?mod=topic&topic={R:2}&{R:3}"/>
</rule>
<rule name="portal_article">
<match url="^(.*/)*article-([0-9]+)-([0-9]+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/portal.php?mod=view&aid={R:2}&page={R:3}&{R:4}"/>
</rule>
<rule name="forum_forumdisplay">
<match url="^(.*/)*forum-(\w+)-([0-9]+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/forum.php?mod=forumdisplay&fid={R:2}&page={R:3}&{R:4}"/>
</rule>
<rule name="forum_viewthread">
<match url="^(.*/)*thread-([0-9]+)-([0-9]+)-([0-9]+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/forum.php?mod=viewthread&tid={R:2}&extra=page%3D{R:4}&page={R:3}&{R:5}"/>
</rule>
<rule name="group_group">
<match url="^(.*/)*group-([0-9]+)-([0-9]+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/forum.php?mod=group&fid={R:2}&page={R:3}&{R:4}"/>
</rule>
<rule name="home_space">
<match url="^(.*/)*space-(username|uid)-(.+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/home.php?mod=space&{R:2}={R:3}&{R:4}"/>
</rule>
<rule name="home_blog">
<match url="^(.*/)*blog-([0-9]+)-([0-9]+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/home.php?mod=space&uid={R:2}&do=blog&id={R:3}&{R:4}"/>
</rule>
<rule name="forum_archiver">
<match url="^(.*/)*(fid|tid)-([0-9]+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/index.php?action={R:2}&value={R:3}&{R:4}"/>
</rule>
<rule name="plugin">
<match url="^(.*/)*([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+).html\?*(.*)$"/>
<action type="Rewrite" url="{R:1}/plugin.php?id={R:2}:{R:3}&{R:4}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Tip 1. <rule>
The name of the node cannot be repeated.
Tip 2. <match>
The url in it is a regular expression, and the example ^(.*)t/([0-9,a-z]*)
is a commonly used sentence pattern.
^
Match the beginning of the domain name, such as: https://tony.8952.com/
, note that there is a slash after the domain name /
.
(.*)
matches any character.
([0-9,a-z]*)
Matches any number and letter.
Therefore, ^(.*)t/([0-9,a-z]*)
the following URLs can be matched (if the domain name of the website is tony.8952.com
):
Tip 3. <action type="Rewrite" ...>
It means that the type of execution is rewriting, and the url inside is the actual url. {R:1}/list.asp?id={R:2}
The explanation is as follows:
{R:1}
Corresponding to <match>
the content of the first parenthesis of the url in , {R:2}
corresponding to <match>
the content of the second parenthesis of the url in , if there are {R:3}
, {R:4}
, and so on.
So, if the URL that the user visits is
http://tony.8952.com/t/123
http://tony.8952.com/news/t/a1
Then, the corresponding actual URL is
http://tony.8952.com/list.asp?id=123
http://tony.8952.com/news/list.asp?id=a1
Tip 4. According to the above explanation, you should be able to understand the rule2 rewriting rules of the instance.
$
, which is a terminator, indicating that the matched url ends here, and there are no other characters behind it.
([0-9]+)
means match any number.
\.html
Indicates a match .html
.
\?
means match a question mark ?
.
In particular, note that the backslash \
is an escape character, because in a regular expression, a dot .
means matching any character, so you need to add a backslash to escape it, so that it means a dot is matched .
.
Similarly, a question mark ?
is also a meta-symbol, which means matching the previous subexpression zero or one time. Therefore, an escape character needs to be added in front of it, \
which means that a question mark is matched ?
.
Tip 5. Others
ignoreCase="false"
Indicates that case cannot be ignored. If the value is set true
, it means that case is ignored.
appendQueryString="false"
Indicates that no url parameters are used.
MR Virtual Live
- MR live broadcast instance (mixed reality live broadcast) high-quality enterprise live broadcast
- How about a virtual stage scene for the live broadcast of the corporate annual meeting?
- MR live broadcast (mixed reality live broadcast) to do a high-quality corporate training
- MR scene live broadcast-help enterprises to carry out more interesting employee training efficiently
- Instance effect of enterprise multi-venue video live broadcast (main venue, branch venue live broadcast)
- How to do virtual live broadcast (virtual scene live broadcast)?
Live Streaming Without Latency
- No-delay live broadcast/ultra-low delay live broadcast screen synchronization test (actual test group pictures)
- Get the enterprise video live broadcast: hardware equipment, live broadcast network environment and equipment connection instructions
- Example Effect Case of No-Delay/No-Delay Video Live Streaming
- OBS Lag-Free Video Live Streaming Complete Tutorial (Photos)
- Millisecond-level ultra-low latency live product measurement (PRTC live broadcast/webRTC live broadcast)
Video Encryption and Security
- How to prevent corporate training videos from being downloaded and stolen?
- What can be learned from the methods of video encryption, anti-download and anti-theft in online educational institutions
- New: Video encryption function adds anti-recording (random watermark) function
- Two ways to achieve double-speed video playback (video player double-speed 1.5x/2x)
- How does the video encryption of teaching course content of education and training institutions be done?