在狗爹哪里注册的域名价格虽然便宜,可以不能实现URL转发。不过狗爹送了一个免费的空间,那就利用空间放个页面,实现PHP或者javascript的转发吧。
下面就是两种代码的写法。
第一种:javascript代码判断输入的网址URL而跳转到相应页面的URL
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>
<script language= "JavaScript ">
<!--
function redir()
{
var theUrl=window.location.toString();
alert(theUrl);
switch(theUrl)
{
case "aa.com ":
window.location= "aaa ";
break;
case "bb.com ":
window.location= "bbb ";
break;
default:
window.location= "default.asp ";
break;
}
}
//-->
</script>
<body onLoad= "redir() ">
</BODY>
</HTML>
第二种:php代码判断输入的网址URL而跳转到相应页面的URL
<?php
//echo 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
$sUrl = $_SERVER['SERVER_NAME'];
if ($sUrl=="127.0.0.1")
{
echo '<meta http-equiv="refresh" content="0; url=http://www.ideasbus.net">';
}
if ($sUrl=="localhost")
{
echo '<meta http-equiv="refresh" content="0; url=http://www.ideasbus.net">';
}
/*
<?
Header("Location: http://www.vanidea.com");echo '<meta http-equiv="refresh" content="0; url=http://www.vanidea.com">';
echo "<script language='javascript'>";
echo " location='http://www.ideasbus.net';";
echo "</script>";
?>
*/
?>
js实现页面跳转的几种方式的总结:
第一种:
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
第二种:
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>
第三种:
<script language="javascript">
window.navigate("top.jsp");
</script>
第四种:
<script language="JavaScript">
self.location='top.htm';
</script>
第五种:
<script language="javascript">
alert("非法访问!");
top.location='xx.jsp';
</script>
1 Comments