简体   繁体   English

Bitnami上的虚拟主机子域指向同一页面

[英]Virtual host subdomain on Bitnami points to the same page

I want to create two subdomains pointing to different folders in a Apache server (running the Bitnami Wamp Stack) so that entering "codeigniter.example.com" shows the content at "\\frameworks\\codeigniter\\htdocs" and "codeignitertwo.example.com" shows "\\frameworks\\codeignitertwo\\htdocs". 我想在Apache服务器(运行Bitnami Wamp Stack)中创建两个指向不同文件夹的子域,以便输入“ codeigniter.example.com”显示“ \\ frameworks \\ codeigniter \\ htdocs”和“ codeignitertwo.example.com”中的内容”显示“ \\ frameworks \\ codeignitertwo \\ htdocs”。

My configurations are the following, the "bitnami-apps-vhosts.conf" includes both framework's virtual hosts: 我的配置如下,“ bitnami-apps-vhosts.conf”包括两个框架的虚拟主机:

Include "/frameworks/codeigniter/conf/httpd-vhosts.conf"
Include "/frameworks/codeignitertwo/conf/httpd-vhosts.conf"

The httpd-vhosts.conf file from the first domain contains: 来自第一个域的httpd-vhosts.conf文件包含:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName codeigniter.example.com
  ServerAlias codeigniter.example.com
  DocumentRoot "/frameworks/codeigniter/htdocs"
  <Directory "/frameworks/codeigniter/htdocs">
    Options +MultiViews
    AllowOverride None

    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>

  </Directory>
</VirtualHost>

While the httpd-vhosts.conf file from the second domain contains (it is almost the same): 来自第二个域的httpd-vhosts.conf文件包含(几乎相同):

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName codeignitertwo.example.com
  ServerAlias codeignitertwo.example.com
  DocumentRoot "/frameworks/codeignitertwo/htdocs"
  <Directory "/frameworks/codeignitertwo/htdocs">
    Options +MultiViews
    AllowOverride None

    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>

  </Directory>  
</VirtualHost>

Both subdomain names are correctly created on the hosts file like this (I'm testing on localhost): 像这样在主机文件上正确创建了两个子域名(我正在localhost上测试):

127.0.0.1       localhost
127.0.0.1       codeigniter.example.com
127.0.0.1       codeignitertwo.example.com

When I access "codeigniter.example.com" the correct page loads however when accessing "codeignitertwo.example.com" the first subdomain loads, like if it the DocumentRoot was "/frameworks/codeigniter/htdocs". 当我访问“ codeigniter.example.com”时,将加载正确的页面, 但是在访问“ codeignitertwo.example.com”时,将加载第一个子域,例如DocumentRoot是否为“ / frameworks / codeigniter / htdocs”。 Why this happens? 为什么会这样? What I'm doing wrong? 我做错了什么?

Update: I restart the Apache service after each change. 更新:每次更改后,我都会重新启动Apache服务。

Thanks. 谢谢。

Finally I solved it! 终于我解决了!

Word of advice to anyone trying to create a virtual host while using a Framework (like Codeigniter and probably CakePHP), if you are completely sure you did a correct virtual host configuration, then you are probably facing incorrect path variables inside the framework. 对任何尝试在使用框架时创建虚拟主机的人(如Codeigniter以及CakePHP),如果您完全确定自己做了正确的虚拟主机配置,则可能会在框架内遇到错误的路径变量。

The way to solve is actually very simple, look at the "index.php" from your htdocs and fix the following variables: 解决的方法实际上非常简单,请查看htdocs中的“ index.php”并修复以下变量:

$system_path, $application_folder $ system_path,$ application_folder

Also you might need some changes in the configuration folder of your framework. 另外,您可能需要在框架的配置文件夹中进行一些更改。

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

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