0

Using Apache. I have a txt file of domains that I want to use for mapping directory aliases. But I can't figure it out.

The txt-file looks like this:

example.com folder1
anotherexample.com folder2
subdomain.example.com folder3
...500 domains...

A request to example.com/data/ should resolve /var/private/folder1/.

I have tried the following in my virtualhost directive:

<VirtualHost *:80>
  ServerName www.site.com
  ServerAlias *.site.com

  DocumentRoot "/var/www/project"

  RewriteEngine On
  RewriteMap ref "txt:/var/path/to/domains.map"
  RewriteCond ${ref:%{HTTP_HOST}} ^.+$
  RewriteRule ^/data "/var/private/${ref:%{HTTP_HOST}}" [L]
</VirtualHost>
Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
tim
  • 101
  • 1

1 Answers1

0

The problem may be that you're trying to redirect a bunch of other domains, from within the virtual host for site.com. If site.com isn't the default virtual host, then your RewriteRule will never be executed.

The solution would be to move the rewrites outside of all of your virtual host containers, or into the default virtual host.

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