国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

web服務器去掉域名www的301重定向設置方法

2024-04-27 15:18:45
字體:
來源:轉載
供稿:網友

是本文介紹web服務器301跳轉方法,實現強制從www.liuyanzhao.com跳到liuyanzhao.com

一、空間的偽靜態版本為ISAPI Rewrite 3.1,需要設置301重定向的,只用修改偽靜態規則文件( .htaccess )即可。

RewriteEngine onRewriteCond %{HTTP_HOST} ^www.liuyanzhao.com [NC]RewriteRule ^(.*)$ http://liuyanzhao.com/$1 [L,R=301]

將以上代碼保存到文件名 .htaccess后上傳到空間根目錄即可。liuyanzhao.com 換成你自己的域名。

二、可用程序實現301重定義,只需修改程序即可。

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 关岭| 丰镇市| 秦皇岛市| 绥江县| 平南县| 灵台县| 龙泉市| 内丘县| 垫江县| 玛纳斯县| 措勤县| 汉川市| 拉孜县| 石景山区| 广德县| 荆门市| 泉州市| 新晃| 清水县| 宜川县| 江西省| 武隆县| 陵川县| 贡嘎县| 道真| 枞阳县| 黔西县| 临江市| 麻栗坡县| 亳州市| 丰城市| 邵阳市| 岚皋县| 慈溪市| 广丰县| 呼伦贝尔市| 定远县| 满洲里市| 涿州市| 蓬莱市| 德令哈市|