美文网首页
iis和apache中SEO优化相关配置

iis和apache中SEO优化相关配置

作者: gao922699 | 来源:发表于2022-08-01 09:30 被阅读0次

    IIS服务器 web.config

    http://go.microsoft.com/fwlink/?LinkId=169433 官方文档

    主域301跳WWW

    <rewrite>
    <rules>
    <rule name="WWW Redirect" stopProcessing="true">
    <match url=".*"/>
    <conditions>
    <add input="{HTTP_HOST}" pattern="^cqjft.com$"/>
    </conditions>
    <action type="Redirect" url="http://www.cqjft.com/{R:0}" redirectType="Permanent"/>
    </rule>
    </rules>
    </rewrite>
    

    iis配置不管用时asp的写法:在index.asp文件最上方加入:

    <% website=request.ServerVariables("Server_name") 
    
    if website="xiaochipeixun.com" then 
    
    Response.Status="301 Moved Permanently" 
    
    Response.AddHeader "Location","http://www.xiaochipeixun.com/" 
    
    end if %>
    

    指定404页面

    <customErrors mode="RemoteOnly" defaultRedirect="404.aspx">
        <error statusCode="404" redirect="404.aspx"/>
    </customErrors>
    

    统一首页地址(index.html301跳转)

    <rewrite>
    <rules>
    <rule name="index">
    <match url="index.html" ignoreCase="true" />
    <action type="Redirect" url="http://www.cqjft.com/"  redirectType="Permanent" />
    </rule>
    </rules>
    </rewrite>
    

    指定规则的urlRewrite

    <rewrite>
    <rules>
    <rule name="news3">
    <match url="^news-([0-9]+)-p([0-9]+).html" />
            <action type="Rewrite" url="xinwen_list.asp?id={R:1}&amp;page={R:2}"  />
        </rule>
    </rules>
    </rewrite>
    

    apache服务器 .htaccess

    http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule 官方文档

    主域301跳WWW

    <ifmodule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^yunfengshangwu.com$ [NC]
        RewriteRule ^(.*)$ http://www.yunfengshangwu.com/$1 [R=301,L]
    </ifmodule>
    

    统一首页地址(index.html301跳转)

    RewriteCond %{REQUEST_URI} ^/index.html$ [NC]
    RewriteRule ^(.*)$ http://www.youxio.cn/ [R=301,L]
    

    指定404页面

    ErrorDocument 404 /404.html
    

    指定规则的urlRewrite

    <ifmodule mod_rewrite.c>
    RewriteEngine on
    RewriteRule n([0-9]{1,})_([0-9]{1,})\.html$ index.php?page_id=$1&NewsID=$2 [NC,L]
    </ifmodule>
    

    相关文章

      网友评论

          本文标题:iis和apache中SEO优化相关配置

          本文链接:https://www.haomeiwen.com/subject/lxuxwrtx.html