A scheme of URL rewriting

Source: Internet
Author: User

URL rewriting can make the website look more organized, and make the old connections after the website revision continue to be used.
Refer to the URL recommendations provided by availability expert Jakob Neilsen.

Msdn reference:
English: http://www.microsoft.com/china/msdn/library/webservices/asp.net/URLRewriting.mspx
English: http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/dnaspp/html/urlrewriting. asp

For simplicity, why does each URL end up with aspx? If it is not aspx, it cannot be mapped to ASPnet for processing. To map the/2004/directory to ASPnet for processing, you need a filter in IIS.
I used the filter http://www.qwerksoft.com/products/iisrewrite/download.asp. I have tried several types of products, and they are almost easy to use in iis5.0. When I got to iis6.0, there was a problem. If the directory/2004/exists, it is easy to use. If the directory does not exist, the Error 404 is returned directly. Only this filter can be used before iis6.0 determines that a directory exists.
The content of my configuration file is:
Rewriteengine on
Rewriterule ([^ \ n] *)/$1/default. aspx
In this way, the problem arises, which is equivalent to blocking the setting of the hosts page in IIS. The hosts page can only be default. aspx.

Further, what if I use the/2004 name for access? Because the filter only overwrites the last URL of/, other values cannot be judged. My solution is to write a 404. aspx

Private   Sub page_load () Sub Page_load ( Byval Sender As   Object , Byval E As System. eventargs) Handles   Mybase . Load
Dim Stemp As   String   = Server. urldecode (request. querystring. tostring ())
If (Stemp. Chars (stemp. Length -   1 ) =   " / " C) Then
Server. Transfer ( " / " )
Else
Stemp = Stemp. substring (stemp. indexof ( " ; " ) +   1 )
Response. Redirect (stemp &   " / " )
End   If
End sub

Then, in the IIS property-> custom error message, change the default value of 404 to Message Type: URL, and URL to/404. aspx.
Although the efficiency is relatively low and the redirection is required once, it is better than not being able to access the service because the user has played one/fewer.

You are welcome to add, criticize, and correct your suggestion.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.