是本文介紹web服務器301跳轉方法,實現強制從www.liuyanzhao.com跳到liuyanzhao.com
將以上代碼保存到文件名 .htaccess后上傳到空間根目錄即可。liuyanzhao.com 換成你自己的域名。
1、如果是asp程序,只需在index.asp首頁的頭部加下以下的綠色代碼,liuyanzhao.com換成你自己的域名。
<%if request.ServerVariables("HTTP_HOST")="www.liuyanzhao.com" thenResponse.Status="301 Moved Permanently"Response.AddHeader "Location","http://liuyanzhao.com"Response.Endend if%>2、如果是php程序,只需在index.php首頁的頭部加下以下的綠色代碼,liuyanzhao.com換成你自己的域名。
<?phpif($_SERVER["HTTP_HOST"] == "www.liuyanzhao.com"){header("HTTP/1.1 301 Moved Permanently");header("Location:http://liuyanzhao.com");}?>3、如果ASP程序,但首頁是html靜態的實現301
<%if request.ServerVariables("HTTP_HOST")="www.liuyanzhao.com" thenResponse.Status="301 Moved Permanently"Response.AddHeader "Location","http://liuyanzhao.com"Response.Endend if%><!--#include file="index.html" -->把上面代碼保存為index.asp(如果文件名有存在可改為 301.asp等)上傳到WEB目錄下,并在管理平臺的“修改默認首頁”把index.asp(如改成其他文件名就要填其他文件名301.asp等)調到 最前面。(index.html為你首頁的靜態文件名)
4、如果PHP程序,但首頁是html靜態的實現301
<?phpif($_SERVER["HTTP_HOST"] == "www.liuyanzhao.com"){header("HTTP/1.1 301 Moved Permanently");header("Location:http://liuyanzhao.com");}?><?php include('index.html'); ?>把上面代碼保存為index.php(如果文件名有存在可改為301.php等)上傳到WEB目錄下,并在管 理平臺的“修改默認首頁”把index.php(如改成其他文件名就要填其他文件名301.php等)調到最前面。(index.html為你首頁的靜態 文件名) 原文地址:http://liuyanzhao.com/1665.html 5、如果你是asp.net 設置方法差不多相同,可以去百度搜索下”.net 301” 找相關教程。
6、如果你二級欄目或內容頁也想實現301,也可以到百度搜索相關的程序教程。
7、http://tool.chinaz.com/pagestatus/ 此工具可以查看設置后有沒有生效。
8.app.conf配置
handlers:- url: / script: /index.html- redirect_host: www.liuyanzhao.com status_code: 301 new_host: liuyanzhao.com- rewrite_not_exist: (.*) script: /index.php/$1原文地址:http://liuyanzhao.com/1665.html
新聞熱點
疑難解答