代码301完美解决虚拟空间永久重定向
- <% if left(request.ServerVariables(“HTTP_HOST”),4)<>”www.” then
- url = “http://www.”&request.ServerVariables(“HTTP_HOST”)
- if Request.ServerVariables(“QUERY_STRING”) <> “” then
- url = url & Request.ServerVariables(“SCRIPT_NAME”) & online casino game “?” & Request.ServerVariables(“QUERY_STRING”)
- end if
- Response.Status = “301 Moved Permanently”
- Response.AddHeader “Location”, url
- end if %>
- <!–#include file=”index.htm”–>
第二步、网站默认启动首页为index.asp;
第三步、调用原来的首页;
下面给出php301代码:
- <?php if(substr($_SERVER["HTTP_HOST"],0,4)!=”www.”)
- {
- $url= “http://www.”.$_SERVER["HTTP_HOST"];
- if ($_SERVER["QUERY_STRING"]!=”") {
- $url = $url.$_SERVER["SCRIPT_NAME"] .”?”.$_SERVER["QUERY_STRING"];
- }
- header(“HTTP/1.1 301 Moved Permanently”);
- header(“location:$url”); } ?>
- <!–#include file=”index.html”–>