adelriosantiago
adelriosantiago

Reputation: 8124

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".

My configurations are the following, the "bitnami-apps-vhosts.conf" includes both framework's virtual hosts:

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

The httpd-vhosts.conf file from the first domain contains:

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):

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):

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". Why this happens? What I'm doing wrong?

Update: I restart the Apache service after each change.

Thanks.

Upvotes: 2

Views: 3447

Answers (1)

adelriosantiago
adelriosantiago

Reputation: 8124

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.

The way to solve is actually very simple, look at the "index.php" from your htdocs and fix the following variables:

$system_path, $application_folder

Also you might need some changes in the configuration folder of your framework.

Upvotes: 1

Related Questions