是否可以在 tomcat servlet 中禁用 jsessionid? [英] Is it possible to disable jsessionid in tomcat servlet?

查看:35
本文介绍了是否可以在 tomcat servlet 中禁用 jsessionid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在tomcat中是否可以关闭url中的jsessionid?jsessionid 似乎对搜索引擎不太友好.

Is it possible to turnoff jsessionid in the url in tomcat? the jsessionid seems not too search engine friendly.

推荐答案

您可以仅禁用使用此过滤器的搜索引擎,但我建议将其用于所有响应,因为它比仅仅使用更糟搜索引擎不友好.它公开了可用于某些安全漏洞的会话 ID(更多信息).

You can disable for just search engines using this filter, but I'd advise using it for all responses as it's worse than just search engine unfriendly. It exposes the session ID which can be used for certain security exploits (more info).

Tomcat 6(6.0.30 之前的版本)

您可以使用 tuckey 重写过滤器.

示例配置:

<outbound-rule encodefirst="true">
  <name>Strip URL Session ID's</name>
  <from>^(.*?)(?:;jsessionid=[^?#]*)?(?[^#]*)?(#.*)?$</from>
  <to>$1$2$3</to>
</outbound-rule>

Tomcat 6(6.0.30 及更高版本)

您可以在上下文配置中使用 disableURLRewriting 来禁用这种行为.

You can use disableURLRewriting in the context configuration to disable this behaviour.

Tomcat 7 和 Tomcat 8

Tomcat 7 起,您可以添加会话配置中的以下内容.

From Tomcat 7 onwards you can add the following in the session config.

<session-config>
    <tracking-mode>COOKIE</tracking-mode>
</session-config>

这篇关于是否可以在 tomcat servlet 中禁用 jsessionid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆