只是想知道这是否可行?
您可以使用htaccess或位于"文件夹"文件夹中的单个HTML文件。
只需在文件夹中添加一个index.html文件即可。然后添加以下代码:
<!DOCKTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=http://example.com/" />
</head>
<body>
You will be redirected...
</body>
</html>
meta标签中的"0"定义了访问者重定向后的秒数。如果他应该在页面上停留5秒,请键入5。
当然,有很多方法可以实现。
在/folder/:中,你身体头部的元刷新
<meta http-equiv="refresh" content="0; url=http://example.com/" />
/folder/redirecting中的小型javascript重定向到根目录。
<script>window.location.href = '/'</script>
在PHP中,您可以使用
header('Location: /');
以重定向您的访问者。
另一种方法是使用htaccess的重写模块
Redirect /old_dir/ http://www.yourdomain.com/new_dir/index.html
或者,如果你正在使用NginX,你的服务器中的一个新位置将起作用:
rewrite ^(.*) http://www.example.com/$1 permanent;
所以这真的取决于你想要什么考试。如果你知道上面的一些解决方案更好,甚至无效。例如,使用reqrite选项(最后两个),您可以告诉spider(google)页面是永久(301)或临时(302)重新定位的。
Web应用程序服务器通常加载默认页面,如index.html。在你的"文件夹"中,你可以添加这样的HTML页面:
绝对路径:
<HTML>
<HEAD>
<META http-equiv="refresh" content="0; url=http://example.com" />
</HEAD>
</BODY>
</BODY>
</HTML>
相对路径:
<HTML>
<HEAD>
<META http-equiv="refresh" content="0; url=.." />
</HEAD>
</BODY>
</BODY>
</HTML>
JS风格:
<HTML>
<HEAD>
</HEAD>
</BODY onload="document.location.href='..'">
</BODY>
</HTML>