0

I've got a domain (example.com) pointed to an apache2 webserver.

the root www folder looks like:

www/
  site/
  app/
  test/

The apache config should:

  • send all requests to http://www.example.com/ to the 'site' folder.
  • send all other subdomain requests to the 'app' folder, while setting the subdomains name as a environment variable.

I am sure that the DNS settings are correct, all urls get resolved to my webserver.

This is what I got in my apache configuration:

<VirtualHost *:80>
    <Directory />
            Options Indexes FollowSymLinks Includes
            AllowOverride All
            Order deny,allow
            Allow from all
            Require all granted
    </Directory>
    ServerName www.example.be
    ServerAlias www.example.be
    DocumentRoot /var/www/site
    ErrorLog ${APACHE_LOG_DIR}/site/error.log
    CustomLog ${APACHE_LOG_DIR}/site/access.log combined
</VirtualHost>

<VirtualHost *:80>
    <Directory />
            Options Indexes FollowSymLinks Includes
            AllowOverride All
            Order deny,allow
            Allow from all
            Require all granted
    </Directory>
    ServerName example.be
    ServerAlias *.example.be
    VirtualDocumentRoot /var/www/app/production/source
    SetEnv VAR_NAME %1
    ErrorLog ${APACHE_LOG_DIR}/site/error.log
    CustomLog ${APACHE_LOG_DIR}/site/access.log combined
</VirtualHost>

The first VirtualHost, the www rewrite to the site folder works as it should be.

The second one does a correct rewrite, but I can't put the subdomain in the environment variable.

Can anyone help me with this last step? I'm not really an apache expert...

Thanx!

gait
  • 1
  • 1
  • 1
    What have you tried so far, and what have the results been? Any log messages you can post? – John Jan 06 '15 at 18:50

1 Answers1

0

You say that a browser can't resolve a URL like http://test.example.com. So is test.example.com a registered hostname in DNS? If not, then your RewriteRule will never get a chance to fire because a client won't be able to find it.

If you're not sure if test.example.com is registered in DNS, try using any online DNS lookup tool, or from the command line run host test.example.com (Linux) or nslookup test.example.com (Windows).

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47