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!

1
  • 1
    What have you tried so far, and what have the results been? Any log messages you can post? Commented Jan 6, 2015 at 18:50

1 Answer 1

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

3
  • Thanx Andrew, I've fixed the DNS, so now subdomains like test.domain.com get resolved to my server. Commented Jan 6, 2015 at 20:08
  • Good. So does that fix your problem? Please edit your post to clarify. Commented Jan 6, 2015 at 21:16
  • I've updated the question. I've made some progress but I got blocked at the environment variable. Commented Jan 6, 2015 at 22:20

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.