1

I'm trying to set something up on my server.

Say there's 2 developers, AAA and BBB, and there browsers contain AAA or BBB in there user agent string. I have 3 directories in the folder /home/dev/, public_html, public_html_AAA, and public_html_BBB. Is it possible to route the developer to there respective folder, and everybody else to just public_html?

I've seen this about BrowserMatch and SetEnvIf, which seems like it could be part of the solution, but I don't know how I'd fit it in.

Here's an example VirtualHost config.

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    DocumentRoot /home/dev/public_html
    ServerName dev.example.com
    ErrorLog /home/dev/logs/apache_log
</VirtualHost>
TMH
  • 143
  • 1
  • 7
  • I don't know if you can set the docroot that way. But alternatively you could create subdomains aaa.example.org and bbb.example.org and use a RewriteCond. Or you could create two subdirectories and make a RewriteCond to www.example.org/aaa or www.example.org/bbb. – Lukas Nov 27 '14 at 14:10
  • The subdomain is our second idea, this was just something I haven't tried doing before, so I thought I'd look into it see if it is do-able or not. – TMH Nov 27 '14 at 14:13
  • The DocumentRoot is a static apache directive and not dynamic. The normal approach are rewrite rules that dynamically serve different content based on certain conditions. In apache mod_rewrite http://serverfault.com/questions/214512/redirect-change-urls-or-redirect-http-to-https-in-apache-everything-you-ever – HBruijn Nov 27 '14 at 14:31
  • The DocumentRoot can contain variables. I've never tried something quite this dynamic myself, but the page at http://httpd.apache.org/docs/2.2/vhosts/mass.html has good info for doing something similar via the requested server name. Not the same, for sure, and it would still use multiple vhosts, just generate them dynamically. – kapn Nov 27 '14 at 16:18

0 Answers0