tomcat 301很明显不提供此功能应该更正确的叫做JAVA301,适合要做友好SEO的朋友
不多做解释,做SEO的话JAVA基本选urlrewrite,所以下面讲的是如何结合urlrewrite做域名跳转。对于301此文章基本是精华贴了。下面直接贴代码。
注意下面的condition不是指你要拦截什么域名而是与你要跳转的域名相对应,比如VeVB.COm跳www.VeVB.COm 那就在condition填www.VeVB.COm
第一种urlrewrite配置:
复制代码代码如下:
<urlrewrite>
<rule>
<name>seo redirect</name>
<condition name="host" operator="notequal">^www.VeVB.COm</condition>
<from>^/(.*)</from>
<to type="permanent-redirect" last="true">//www.VeVB.COm/$1</to>
</rule>
</urlrewrite>
第二种urlrewrite配置:
复制代码代码如下:
<urlrewrite>
<rule>
<name>seo redirect</name>
<condition name="host" operator="notequal">^www.VeVB.COm</condition>
<condition name="host" operator="notequal">^localhost</condition>
<from>^/(.*)</from>
<to type="permanent-redirect" last="true">//www.VeVB.COm/$1</to>
</rule>
</urlrewrite>