17370845950

tomcat301与java301解析

tomcat 301很明显不提供此功能应该更正确的叫做JAVA301,适合要做友好SEO的朋友

不多做解释,做SEO的话JAVA基本选urlrewrite,所以下面讲的是如何结合urlrewrite做域名跳转。对于301此文章基本是精华贴了。下面直接贴代码。

注意下面的condition不是指你要拦截什么域名而是与你要跳转的域名相对应,比如跳www. 那就在condition填www.

第一种urlrewrite配置:

复制代码 代码如下:
<urlrewrite>
    <rule>
        <name>seo redirect</name>
        <condition name="host" operator="notequal">^www.</condition>
        <from>^/(.*)</from>
        <to type="permanent-redirect" last="true">https://www./$1</to>
    </rule>
</urlrewrite>

第二种urlrewrite配置:
复制代码 代码如下:
<urlrewrite>
    <rule>
        <name>seo redirect</name>
        <condition name="host" operator="notequal">^www.</condition>
        <condition name="host" operator="notequal">^localhost</condition>
        <from>^/(.*)</from>
        <to type="permanent-redirect" last="true">https://www./$1</to>
    </rule>
</urlrewrite>