zoukankan      html  css  js  c++  java
  • IIS服务器下301跳转是怎么样实现的?

            301跳转的用法很多,对于一名SEO来说,301转向是必须掌握的本领,但是对于301转向而言,许多人都并不清楚,301跳转以后,需不需要对原网站进行优化,再次提及一边301跳转的定义。

            所谓301跳转,对于搜索引擎而言,便是,对搜索引擎发出信息,告诉搜索引擎:“此url地址已经永久的进行跳转到了‘XXX’url地址。”而对于用户而言,301跳转后的网站,在用户使用的时候,输入旧的地址,会自动跳转到新的地址,只是这个过程及其迅速,不可察觉而已。

         各种程序、服务器下301跳转的实现:


        一: IIS服务器中实现301跳转:
        1.打开internet信息服务管理器,在欲重定向的网页或目录上按右键 
        2.选中“重定向到URL” 
        3.在对话框中输入目标页面的地址 
        4.选中“资源的永久重定向” 
        5.点击“应用”。

        二:ASP下的301转向代码:

        1.<%@ Language="VBScript" %>
     

        2.<%
     

        3.Response.Status = "301 Moved Permanently"
     

        4.Response.AddHeader "Location", "http://www.url.com"
     

        5.%>
     

        三、PHP下的301转向代码:

    1. <?
       
    2. header("HTTP/1.1 301 Moved Permanently");
       
    3. header("Location:http://www.url.com");
       
    4. exit();
       
    5. ?>
       

       四:ASP.Net下的301转向代码:

    1. <script runat="server">
       
    2. private void Page_Load(object sender, System.EventArgs e)
       
    3. {
       
    4. Response.Status = "301 Moved Permanently";
       
    5. Response.AddHeader("Location","http://www.url.com");
       
    6. }
       
    7. </script>
       

       五:CGI Perl下的301转向代码:

    1. $q = new CGI;
       
    2. print $q->redirect("http://www.url.com");
       

       六:JSP下的301转向代码:

    1. <%
       
    2. response.setStatus(301);
       
    3. response.setHeader( "Location", "http://www.url.com" );
       
    4. response.setHeader( "Connection", "close" );
       
    5. %>

      七:Apache下301转向代码:

       建立.htaccess文件,(需要开启mod_rewrite)

       1)进行url标准化,将不带WWW的域名转向到带WWW的域名下:

    1. Options +FollowSymLinks
       
    2. RewriteEngine on
       
    3. RewriteCond %{HTTP_HOST} ^url.com [NC]
       
    4. RewriteRule ^(.*)$ http://www.url.com/$1 [L,R=301]
       

       2)重定向到新域名:

    1. Options +FollowSymLinks
       
    2. RewriteEngine on
       
    3. RewriteRule ^(.*)$ http://www.url.com/$1 [L,R=301]
       

      八:Apache下vhosts.conf中配置301跳转:

       为实现URL规范化,seo需要将不规范的url地址进行301跳转至规范的url地址

       vhosts.conf中配置为:

       Apache下vhosts.conf中配置301跳转:

    1. <VirtualHost *:80>
       
    2. ServerName www.url.com
       
    3. DocumentRoot /home/lesishu
       
    4. </VirtualHost>
       

    5.  
    6. <VirtualHost *:80>
       
    7. ServerName url.com
       
    8. RedirectMatch permanent ^/(.*) http://www.url.com/$1
       
    9. </VirtualHost>

       九:Ruby中实现301跳转:

       Ruby中实现301跳转:

    1. def old_action
       
    2. headers["Status"] = "301 Moved Permanently"
       
    3. redirect_to "http://www.url.com"
       
    4. end

      十:Coldfusion中实现301跳转:

      Coldfusion中实现301跳转:

    1. <.cfheader statuscode="301" statustext="Moved permanently">
       
    2. <.cfheader name="Location" value="http://www.url.com">

      通过整理的这些301转向的代码希望这些各种程序的301代码写法能够让你对于301的写法有充分的认识。并通过实际的运用完全掌握301跳转的用法。

      老张交流QQ:2881064151

  • 相关阅读:
    [Swift]LeetCode922.按奇偶排序数组 II | Sort Array By Parity II
    [Swift]LeetCode921.使括号有效的最少添加 | Minimum Add to Make Parentheses Valid
    [Swift实际操作]八、实用进阶-(5)通过间接代理进行对象间的消息传递
    [Swift]LeetCode927. 三等分 | Three Equal Parts
    [Swift]LeetCode928. 尽量减少恶意软件的传播 II | Minimize Malware Spread II
    我是大牛,我自豪
    程序员拓展人脉的重要性
    程序员拓展人脉的重要性
    2013年总结(3)-活动篇
    2013年总结(3)-活动篇
  • 原文地址:https://www.cnblogs.com/cbryge/p/5935779.html
Copyright © 2011-2022 走看看