ASP.NET site pseudo static using Chinese URL method

  • 2021-01-19 22:04:35
  • OfStack

First of all, what is Chinese URL? Instead of encoding Chinese characters as %CF%EC as we usually do, we use Chinese characters directly in URL

This form is not very common at the moment. This may be done differently by different browsers, but in my tests, ES7en8 and ES8en are fully supported.

The advantage of it is that you can use the link address to look very intuitive! Search engines also support it.

Let's start with the pseudo static version of my ASP.NET website. My files end with.htm, but it's actually dynamic ASP. This is done by mapping htm to aspx files in the background.

The pseudo-static rules are defined in web.config.

Form 1:

https: / / www. ofstack. com/Beijing. htm

Pseudo static code


<Rules>
<RewriterRule>
<LookFor>~/([^ Provinces and cities to ]+)[ province | The city ]\.htm</LookFor>
<SendTo>
<![CDATA[~/prov.aspx?provname=$1]]>
</SendTo>
</RewriterRule>
</Rules>

Form 2:

https: / / www. ofstack. com / / hankou of hubei province. htm


<Rules>
<RewriterRule>
<LookFor>~/([^/]+)/(\w+)\.htm</LookFor>
<SendTo>
<![CDATA[~/city.aspx?provname=$1&cityname=$2]]>
</SendTo>
</RewriterRule>
</Rules>

The actual code handling is implemented in the prov. aspx and city. aspx background files, but pseudo-static completely hides this point.


Related articles: