5fc8ff12c3fb21597.jpg_fo742.jpg
下载UrlRewriteFilter
wget http://urlrewritefilter.googlecode.com/files/urlrewritefilter-4.0.3.jar
并放入tomcat的 WEB-INF/lib下
配置tomcat
编辑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>

添加跳转规则,在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/</to>
  </rule>
</urlrewrite>

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code