Reply To: Rewrite + Apache Shiro

Splash Forums Rewrite Users Rewrite + Apache Shiro Reply To: Rewrite + Apache Shiro

#23893

The RewriteFilter is automatically registered in Servlet 3.0 environments. But if you want to have more control in regard to filter ordering, you will have to add it yourself.

You could try to place the Rewrite filter after the Shiro filter like this:


<!-- Shiro first, no dispatcher setting required -->
<filter>
  <filter-name>ShiroFilter</filter-name>
  <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>ShiroFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Rewrite after that -->
<filter>
  <filter-name>OCPsoft Rewrite Filter</filter-name>
  <filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
  <async-supported>true</async-supported>
</filter>
<filter-mapping>
  <filter-name>OCPsoft Rewrite Filter</filter-name>
  <url-pattern>/*</url-pattern>
  <dispatcher>FORWARD</dispatcher>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>INCLUDE</dispatcher>
  <dispatcher>ASYNC</dispatcher>
  <dispatcher>ERROR</dispatcher>
</filter-mapping>

In this case Shiro only “sees” the pretty URLs. So you also have to use the pretty URLs in shiro.ini