URL Rewrite URL explanation and example

UrlRewrite rewrite URL details

UrlRewrite is what we usually call address rewriting. All users get are processed URL addresses.

UrlRewrite, as the name suggests, is to rewrite the URL. All the URLs that users get are processed URLs. I think this has three advantages:

1: Improving security can effectively prevent some parameter names and IDs from being completely exposed to users. If users randomly input, if they do not comply with the rules, they will directly return a 404 or error page, which is much better than directly returning 500 or a lot of server error information

2: Beautify URLs and remove those such as * Suffixes such as do and long parameter strings can be organized and streamlined by themselves, which can better reflect the URL of accessing module content

3: It is more conducive to the income of the search engine. Through some optimization of the URL, the search engine can better identify and include the information of the website

Use steps

1 download jar

Official address: http://tuckey.org/urlrewrite/ Download urlrewritefilter-4.0 3. Jar and add it to the project lib directory.

2. Configure web xml

3. Configure UrlRewrite xml

Add UrlRewrite XML to the WEB-INF directory of the project.

Summary:

UrlRewrite is a filter. It will filter all user requests and redirect them if they meet the rules. The from rules in the rule node are matched by regular expressions by default,

When the user accesses the server, the URL will be compared with the configuration. If the rules are met, it will jump according to the configuration in the following to node. The default is forward jump.

Simply analyze the above regular expression "^ / vweb / view / index - ([0-9] +)": "" match the start position of the input string "" match the end position of the input string

"\" escape character, indicating that the following "-" has no special meaning, but is a simple string. "([0-9] +)": "[0-9]": the string "+" composed of any data from 0 to 9 matches 1 or more characters just before it.

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>