简体   繁体   English

重定向到新网站

[英]Redirect to New Website

I made two folders in root called "oldwebsite" and "newwebsite". 我在根目录下创建了两个文件夹“ oldwebsite”和“ newwebsite”。

Suppose domain is www.example.com 假设网域是www.example.com

If someone goes to www.example.com it has to go to index on the root folder, else if someone goes to www.example.com/newwebsite it has to go to folder newwebsite , else all other has to go to www.example.com/oldwebsite 如果有人访问www.example.com ,则必须转到根文件夹的索引,否则,如果有人访问www.example.com/newwebsite ,则必须转到文件夹newwebsite ,否则所有其他人都必须转到www.example.com/oldwebsite

Please let me know how to redirect from root either using htaccess or php. 请让我知道如何使用htaccess或php从根目录重定向。

old website www.example.com 旧网站www.example.com

if in google shows www.example.com/forum1 如果在谷歌显示www.example.com/forum1
new website www.folder1.example.com 新网站www.folder1.example.com

Another method of doing this is creating an index.php in your root directory: 另一种方法是在根目录中创建index.php:

<?php
header("Location: /newwebsite/");
?>

You can try this in .htaccess file in the root folder itself. 您可以在根文件夹本身的.htaccess文件中尝试此操作。

DirectoryIndex index.html
Redirect /newwebsite http://www.example.com/newwebsite/index.html
Redirect /oldwebsite http://www.example.com/oldwebsite/index.html

Try this 尝试这个
php have header and redirect to page navaigate. php有标题,并重定向到页面导航。

<?php

header("Location: www.example.com/newwebsite/");

//or


Redirect('http://www.example.com/newwebsite');
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM