一、空间的伪静态版本为ISAPI Rewrite 3.1,需要设置301重定向的,只用修改伪静态规则文件( .htaccess )即可。
RewriteEngine on
RewriteCond %{HTTP_HOST} ^128sj.com [NC]
RewriteRule ^(.*)$ https://www.128sj.com/$1 [L,R=301]
将以上绿色代码保存到文件名 .htaccess后上传到空间根目录即可。128sj.com 换成你自己的域名。
二、可用程序实现301重定义,只需修改程序即可。
1、如果是ASP程序,只需在index.asp首页的头部加下以下的绿色代码,128sj.com换成你自己的域名。
<%
if request.ServerVariables("HTTP_HOST")="128sj.com" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.128sj.com"
Response.End
end if
%>
2、如果是PHP程序,只需在index.php首页的头部加下以下的绿色代码,128sj.com换成你自己的域名,首先用FTP工具登录空间根目录,找到首页文件index.php,然后下载保存到本地,用专业编程软件DW等进行编辑,编辑好后保存,上传覆盖原文件。免备案空间如何用FTP上传程序详见《免备案空间如何上传程序》一文。
<?php
if($_SERVER["HTTP_HOST"] == "128sj.com")
{
header("HTTP/1.1 301 Moved Permanently");
header("Location:http://www.128sj.com");
}
?>
3、如果ASP程序,但首页是html静态的实现301
<%
if request.ServerVariables("HTTP_HOST")="128sj.com" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.128sj.com"
Response.End
end if
%>
<!--#include file="index.html" -->
把上面绿色代码保存为index.asp(如果文件名有存在可改为301.asp等)上传到WEB目录下,并在管理平台的“修改默认首页”把index.asp(如改成其他文件名就要填其他文件名301.asp等)调到最前面。(index.html为你首页的静态文件名)
4、如果PHP程序,但首页是html静态的实现301
<?php
if($_SERVER["HTTP_HOST"] == "128sj.com")
{
header("HTTP/1.1 301 Moved Permanently");
header("Location:http://www.128sj.com");
}
?>
<?php include('index.html'); ?>
把上面绿色代码保存为index.php(如果文件名有存在可改为301.php等)上传到WEB目录下,并在管理平台的“修改默认首页”把index.php(如改成其他文件名就要填其他文件名301.php等)调到最前面。(index.html为你首页的静态文件名)