【问题标题】:Redirect multiple subdomains to different specific index.php files将多个子域重定向到不同的特定 index.php 文件
【发布时间】:2020-07-19 23:40:44
【问题描述】:

我使用同一个域托管不同的网站。 我想将每个子域重定向到不同的“index.php” 这是我想做的一个例子:

subdomain1.mydomain.com --> http://subdomain1.mydomain.com/subdomain1/index.php
subdomain2.mydomain.com --> http://subdomain2.mydomain.com/subdomain1/index.php

这是我的文件结构:

/var/www/
    '-- html
        |-- site1
            '-- index.php
        '-- site2
            '-- index.php

我一直在尝试通过使用“.htaccess”文件来实现这一点,但我没有到达那里。

我知道 .htaccess 不是唯一的解决方法。我可以使用 javascrip 或 PHP 脚本

【问题讨论】:

  • 然后为每个子域创建一个虚拟主机,就是这样做的
  • @RiggsFolly 谢谢!我花了一段时间才弄明白,但效果很好!

标签: javascript php apache redirect


【解决方案1】:

您可以使用此代码:

site1-->index.php 代码:

<?php
header('Location: http://subdomain2.mydomain.com/subdomain1/index.php');
?>

site2-->index.php 代码:

<?php
header('Location: http://subdomain1.mydomain.com/subdomain1/index.php');
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-07
    • 2012-01-13
    • 1970-01-01
    • 2018-09-30
    • 2013-09-29
    • 2021-07-03
    • 2013-09-23
    • 2012-03-08
    相关资源
    最近更新 更多