Skip to content

Sample implementation of url rewriting for static html pages using just spring mvc functionality, i.e. without using http://tuckey.org/urlrewrite

Notifications You must be signed in to change notification settings

andifalk/url-rewrite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Rewrite

When searching the web on how to implement url rewriting with spring most of the times you end up on the Turkey url-rewrite filter project.

This demo project instead implements url rewriting for static html pages by using spring mvc and spring boot auto configuration functionality only.

When searching for url rewr

Configuration

The whole configuration is done in application.yml file. Here the path and suffix for html pages to be resolved are configured using predefined spring properties:

  • spring.mvc.view.suffix = .html
  • spring.mvc.view.prefix = /

The mapping between url and the target static html page is configured using customized rewrite property.

rewrite:
    entries:
        - sourceUrl: /first
          target: firstpage
        - sourceUrl: /second
          target: secondpage

With these mappings the following rewrite url mappings are created:

This also works with query parameters as well.

Run the demo

To run the demo just run the class UrlRewriteApplication. After successfully starting the application you can access the two pages by locating your browser to the following url's:

About

Sample implementation of url rewriting for static html pages using just spring mvc functionality, i.e. without using http://tuckey.org/urlrewrite

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published