Converting old php site to spring mvc while maintaining inbound links
I have an old php site that i'm in the process of converting to spring mvc, just for the fun of it. Now, on my php site the navigation links are in the following format: http://www.example.com/?p=blog and so on.
I was thinking that i in my web.xml could add a url-mapping kind of like this:
<servlet-mapping>
<servlet-name>legacyurl</servlet-name>
<url-pattern>/*p=*</u开发者_C百科rl-pattern>
</servlet-mapping>
And then just send a 301, permanently moved to the new correct url.
But from what i can tell the url-pattern isn't allowed, it certainly doesn't work. So what would be a good solution to this? In my spring mvc application i would like to have urls in the form of: http://www.example.com/blog/. But how can i setup a servlet-mapping for the legacy urls?
Use the URL rewrite filter from tuckey.org:
http://www.tuckey.org/urlrewrite/
You set up the filter in web.xml and a config in an external XML file that maps a URL regex to another URL pattern (with full regex replace).
精彩评论