Usually, in order to better relieve server pressure and enhance search engine friendliness, we generate static pages from article content.
But sometimes in order to display some information in real time, or to use dynamic scripts to solve some problems, website content cannot be displayed in a static way, and dynamic page display must be used.
In this way, the friendliness to search engines is lost. How to find a middle method between the two? How to enhance the readability of the addresses in your website and allow search engines to quickly include your site?
This requires you to beautify the address of your web page, which results in pseudo-static technology, which is what we often call Url Rewriter rewriting technology. That is, when we visit a page, what is displayed in the address bar is a static page ending with ".html", but in fact we are visiting a dynamic web page. Here you need to use UrlRewriter technology.
As you are familiar with, there may be many servers that provide URL rewriting technology. In the past, the ones we used most were some URL rewriting that comes with servers such as Apache and Jboss. However, their configuration is more troublesome and their performance is not very good. Now we have a dedicated open source framework to complete Url rewriting tasks. What I want to introduce today is UrlRewriteFilter, which is relatively simple to use. UrlRewriteFilter is a web filter used to rewrite URLs, similar to Apache's mod_rewrite. Works with any web application server (such as Resin, Orion, Tomcat, etc.). Its typical application is to make dynamic URLs static, making it easier for search engine crawlers to crawl your dynamic web pages.
Let’s first take a brief look at the benefits that using URL rewriting can bring to your website.
First: It is beneficial to search engine crawling, because most search engines are still relatively weak at crawling dynamic pages, and they prefer to crawl some static pages. Most of the data on our current page is displayed dynamically. This requires us to turn dynamic pages into static pages, which is beneficial to search engine crawling.
Second: Make it easier for users to understand. Few users care about the address of the page on your website, but it is still necessary to enhance the readability of general large and medium-sized websites. This will make your website more perfect.
Third: To realize the hidden technology, we can hide the technology through Url rewriting. It will not expose the technology you use and provide convenience to some enthusiasts who want to attack your website.
Fourth: It can be easily reused to improve the portability of the website. If we change the background method, we can ensure that the front-end page part does not need to be changed. This improves the portability of the website.
Although it has so many advantages, it also has some disadvantages. Because it is implemented through the filter principle, it is thought that one more access will affect the access speed to some extent, which can be ignored.
UrlRewriter technology now has two technology platforms, one is in the Java direction, and the other is in the .NET direction. Today we are talking about Java-oriented applications.
First, let us understand how it works. To put it bluntly, it is a simple filter. If you look at the source code, you will quickly understand that it is forward() implemented through the two methods we commonly use in jsp. ,sendRedirect().
Below we make a simple application of Url rewriting technology:
Step 1 : Download the urlrewrite-3.2.0beta.jar package and copy urlrewrite-3.2.0beta.jar to the classpath.
Step 2 : Create a urlrewrite.xml configuration file in the WEB-INF directory.
Step 3 : Initialize and configure UrlRewriteFilter in the web.xml configuration file. Add the following code to the configuration file: