国内服务器
亚洲服务器
欧洲服务器
北美洲服务器
南美洲服务器
大洋洲服务器
非洲服务器

首页>>服务器

tomcat服务器怎么做301重定向

发表时间:2022-10-14 09:02:30

tomcat服务器做301重定向的方法:

1.借助UrlRewriteFilter软件,下载命令:

wget http://urlrewritefilter.googlecode.com/files/urlrewritefilter-4.0.3.jar

2.解压并放入到tomcat的WEB-INF/lib目录下。

3.编辑WEB-INF/web.xml文件,在“servlet mapping”前加入以下代码:

<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>

4.在WEB-INF下新建urlrewite.xml文件,加入跳转规则,代码如下:

<urlrewrite>

  <rule>

      <name>seo redirect</name>

      <condition name="host" operator="notequal">^www.example.com</condition>

      <condition name="host" operator="notequal">^localhost</condition>

      <from>^/(.*)</from>

      <to type="permanent-redirect" last="true">http://www.example.com/$1</to>

  </rule>

</urlrewrite>

上一篇 下一篇
最新文章

如何提高云服务器的安全系数

香港独立IP空间有什么优势

香港空间影响百度收录吗

为啥要租用美国VPS

VPS的缺点有哪些

香港vps作用在哪里

VPS的优点有哪些

外贸网站为啥选择美国vps

VPS能建多少个网站

VPS要如何选择位置

相关文章

服务器网络:在线游戏平台租用台湾服务器时需要考虑哪些方面?

如何加强不用备案服务器抵御攻击的能力

韩国服务器验证:保障网络安全的重要步骤

香港云主机无需备案有甚么好处

搭建App香港服务器的重要性及步骤解析

租用香港私人VPS选择哪一个公司好

服务器负载均衡的优点有哪些

租国外云主机

如何选择最价格低香港VPS

怎样把二级目录301重定向到二级域名 两种实用方

X

截屏,微信识别二维码

微信号:muhuanidc

(点击微信号复制,添加好友)

打开微信

微信号已复制,请打开微信添加咨询详情!