zoukankan      html  css  js  c++  java
  • 各种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");

    七 Apache下301转向代码

    1)将不带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通常将不带WWW的域名转向到带WWW域名,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转向

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

    十 Coldfusion中实现301转向

    1. <.cfheader statuscode="301" statustext="Moved permanently">
    2. <.cfheader name="Location" value="http //www url com">
  • 相关阅读:
    自增自减
    字符串处理函数
    指针总结指向const的指针、const指针、指向const指针的const指针
    Jenkins基础篇 系列之-—04 节点配置
    soapUI系列之—-07 调用JIRA Rest API接口【例】
    测试人员转正考核方向
    linux系列之-—03 常见问题
    Jenkins基础篇 系列之-—03 配置用户和权限控制
    linux系列之-—01 shell编程笔记
    Jenkins基础篇 系列之-—02 修改Jenkins用户的密码
  • 原文地址:https://www.cnblogs.com/cdxkyz/p/2964565.html
Copyright © 2011-2022 走看看