简体   繁体   English

如何将子域指向主域子文件夹

[英]How to point the subdomain to Main domain sub folder

I have the site domain.com and creates the need subdomain.domain.com that points to the directory domain.com/public_html/subdomain我有站点 domain.com 并创建指向目录domain.com/public_html/subdomain的需要subdomain.domain.com

How do I do that?我该怎么做?

The subdomain folder must be within the public_html folder domain.com subdomain文件夹必须在public_html文件夹domain.com

The vestaCP possesses the possilidade to choose the root folder of the subdomain ? VestaCP 拥有选择subdomain的根文件夹的可能性吗?

Sorry for my bad English.抱歉我的英语不好。

Simply put:简单地说:

I need it:我需要它:

sub.domain.com> /home/user/web/domain.com/public_html/subdomain

No:否:

sub.domain.com> /home/user/web/sub.domain.com/public_html

I always solve it by one of this 2 ways (each of them has advantages and disadvantages):我总是通过以下两种方式之一解决它(每种方式都有优点和缺点):

  1. I redirect the subdomain by .htaccess file to the folder inder the main domain.我通过 .htaccess 文件将子域重定向到主域下的文件夹。 So i just add Redirect 301 / http://example.com/subfolder to the .htaccess file of subdomain.所以我只是将Redirect 301 / http://example.com/subfolder添加到子域的.htaccess文件中。 It's classic unmasked redirection.这是经典的无掩码重定向。
  2. I make a PHP file index.php in /home/user/web/sub.domain.com/public_html folder with this content: <?php print file_get_contents("https://example.com/subdomain/"); ?>我在/home/user/web/sub.domain.com/public_html文件夹中创建了一个包含以下内容的 PHP 文件 index.php: <?php print file_get_contents("https://example.com/subdomain/"); ?> <?php print file_get_contents("https://example.com/subdomain/"); ?> and in folder /home/user/web/example.com/public_html/subdomain is website. <?php print file_get_contents("https://example.com/subdomain/"); ?>文件夹中的/home/user/web/example.com/public_html/subdomain是网站。 Phe PHP file displays the whole content of website on main domain folder. Phe PHP 文件在主域文件夹中显示网站的全部内容。

None of them is the real solution, it's just a how to hack it, but I hope it will be useful它们都不是真正的解决方案,只是如何破解它,但我希望它会有用

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

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