| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 400 人关注过本帖
标题:发一下我用的cms系统的301跳转代码
只看楼主 加入收藏
yingwu55
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2012-6-10
结帖率:100%
收藏
 问题点数:0 回复次数:1 
发一下我用的cms系统的301跳转代码
做前端的,本来对这些就是一知半解的,参照了一些代码,测试后可用
这里主要是让不熟悉代码的童鞋把不同的网址结构的跳转处理好
下面是我参照的代码(不符合我的网址结构,但符合大多数asp的网址结构)
<%
'修改,301定向到主域名
Dim strHOST,goURL
strHOST = LCase(Request.ServerVariables("HTTP_HOST"))'域名转换为小写
if Request.ServerVariables("QUERY_STRING")<>"" then '含有参数则
   goURL="www.("QUERY_STRING")&"#from301="&strHOST
else   '不含参数则
   goURL="www.
end if
  if strHOST<>"www. then  '域名不是则
    Response.Status = "301 Moved Permanently"
    Response.AddHeader "Location",goURL
    Response.End
  else        
  end if
%>


修改后的代码(可用)

<%
if request.ServerVariables("HTTP_HOST")<>"www. then
if Request.ServerVariables("SCRIPT_NAME")="/?main.html" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","www.
else
if Request.ServerVariables("QUERY_STRING")<>"" then
p="/?"
else
p=""
end if
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","$.

("QUERY_STRING")
Response.End
end if
end if
%>
搜索更多相关主题的帖子: 定向 结构 
2012-09-06 15:42
yingwu55
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2012-6-10
收藏
得分:0 
案例站点
http://www.
'修改,301定向到主域名
Dim strHOST,goURL
strHOST = LCase(Request.ServerVariables("HTTP_HOST"))'域名转换为小写
if Request.ServerVariables("QUERY_STRING")<>"" then '含有参数则
   goURL="www.("QUERY_STRING")&"#from301="&strHOST
else   '不含参数则
   goURL="www.
end if
  if strHOST<>"www. then  '域名不是则
    Response.Status = "301 Moved Permanently"
    Response.AddHeader "Location",goURL
    Response.End
  else        
  end if
%>


修改后的代码(可用)

<%
if request.ServerVariables("HTTP_HOST")<>"www. then
if Request.ServerVariables("SCRIPT_NAME")="/?main.html" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","www.
else
if Request.ServerVariables("QUERY_STRING")<>"" then
p="/?"
else
p=""
end if
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","$.

("QUERY_STRING")
Response.End
end if
end if
%>

lxznchina立鑫智能南昌安防
2012-09-06 15:43
快速回复:发一下我用的cms系统的301跳转代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012230 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved