我正在使用Tomcat 8和Tuckey urlrewrite从我的网页URL中删除“ .jsp”。它的工作正常,但我注意到从页面重定向urlrewrite时,响应标头中的X-Frame-Options不存在。 mysite.com/Home转换为mysite.com/Home.jsp,但未设置X-Frame选项。为我从urlrewirte中排除的所有页面(例如mysite.com/picture.png)设置了它们。任何指导将不胜感激。
Web.xml
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter>
<filter-name>httpHeaderSecurity</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<init-param>
<param-name>antiClickJackingOption</param-name>
<param-value>SAMEORIGIN</param-value>
</init-param>
<init-param>
<param-name>antiClickJackingEnabled</param-name>
<param-value>true</param-value>
</init-param>
</filter>
urlrewrite.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite
PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
<rule match-type="regex">
<condition type="request-url" operator="notequal">jsp$</condition>
<condition type="request-url" operator="notequal">html$</condition>
<condition type="request-url" operator="notequal">pdf$</condition>
<condition type="request-url" operator="notequal">txt$</condition>
<condition type="request-url" operator="notequal">apk$</condition>
<condition type="request-url" operator="notequal">app$</condition>
<condition type="request-url" operator="notequal">zip$</condition>
<condition type="request-url" operator="notequal">avi$</condition>
<condition type="request-url" operator="notequal">flv$</condition>
<condition type="request-url" operator="notequal">mp4$</condition>
<condition type="request-url" operator="notequal">mov$</condition>
<condition type="request-url" operator="notequal">wmv$</condition>
<condition type="request-url" operator="notequal">mp3$</condition>
<condition type="request-url" operator="notequal">wav$</condition>
<condition type="request-url" operator="notequal">jpg$</condition>
<condition type="request-url" operator="notequal">png$</condition>
<condition type="request-url" operator="notequal">/media/.*</condition>
<condition type="request-url" operator="notequal">/css/.*</condition>
<condition type="request-url" operator="notequal">/img/.*</condition>
<condition type="request-url" operator="notequal">/js/.*</condition>
<!-- negative look foward and back expresion to foward match pages that do not end in .jsp -->
<from>/.+(?:(?!jsp).).$</from>
<to type="forward">%{request-uri}.jsp</to>
</rule>
</urlrewrite>
答案 0 :(得分:1)
因此,这似乎不是URL Rewrite的问题,而是包含x-frame-options的httpSecurityHeader过滤器的缺失。添加映射“ / *”后,每个文件现在都设置了antiClickJacking选项。以下是实现这一目标的web.xml设置。
<filter>
<filter-name>httpHeaderSecurity</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<init-param>
<param-name>antiClickJackingOption</param-name>
<param-value>SAMEORIGIN</param-value>
</init-param>
<init-param>
<param-name>antiClickJackingEnabled</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>httpHeaderSecurity</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>