在Spring中将https重定向到http
我已经使用标准过程在Tomcat上运行的应用程序中配置了SSL。我修改了server.xml文件和web.xml,以在每个请求中强制使用https。我应该做两件事中的一件 1) 正在进行的重定向是302重定向。如何将其作为301重定向?这个302重定向不允许谷歌机器人抓取我的网站 或 2) 使用一种机制,在这种机制中,我需要成为http的URL从https重定向到http。 我知道一旦Tomcat被重定向到http,它就不能自动从https重定向到http。我在web.xml中添加了以下条目,以启用对所需url的http访问在Spring中将https重定向到http,http,tomcat,https,url-rewriting,url-redirection,Http,Tomcat,Https,Url Rewriting,Url Redirection,我已经使用标准过程在Tomcat上运行的应用程序中配置了SSL。我修改了server.xml文件和web.xml,以在每个请求中强制使用https。我应该做两件事中的一件 1) 正在进行的重定向是302重定向。如何将其作为301重定向?这个302重定向不允许谷歌机器人抓取我的网站 或 2) 使用一种机制,在这种机制中,我需要成为http的URL从https重定向到http。 我知道一旦Tomcat被重定向到http,它就不能自动从https重定向到http。我在web.xml中添加了以下条目,以
<security-constraint>
<web-resource-collection>
<web-resource-name>SecureConnection</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>UnsecureConnection</web-resource-name>
<url-pattern>/Market/browseMarket.htm</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
安全连接
/*
保密的
不安全连接
/Market/browseMarket.htm
没有一个
但是,一旦Tomcat使用第一个块重定向到https,即使存在第二个块,它也无法重定向回http
我在一些文章中读到了在应用程序中使用URLRirectFilter来实现的。为了实现这一点,我在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>
</filter-mapping>
URL重写过滤器
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
URL重写过滤器
/*
我已将urlrewrite.xml放在WEB-INF下,其内容如下:
<urlrewrite>
<rule>
<from>Market/browseMarket.htm</from>
<to>http://%{server-name}%{request-uri}</to>
</rule>
</urlrewrite>
Market/browseMarket.htm
http://%{server name}%{request uri}
然而,这似乎不起作用,我仍然在那个页面上使用https
有人能帮我解决上述问题吗