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>