我想设置一个虚拟主机,它可以根据用于访问它的主机名动态处理所有请求。如果 %{HTTP_HOST} 可以在 DocumentRoot 中使用,这可能正是我想要的:
<VirtualHost *:80>
ServerAdmin me@example.com
DocumentRoot /var/www/live/%{HTTP_HOST}/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/live/%{HTTP_HOST}/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
ErrorLog /var/www/live/%{HTTP_HOST}/logs/error.log
CustomLog /var/www/live/%{HTTP_HOST}/logs/access.log combined
</VirtualHost>
...不幸的是,DocumentRoot ( ) 中不允许使用 %{HTTP_HOST} Warning: DocumentRoot [/var/www/live/%{HTTP_HOST}/public] does not exist
。我还能如何实现我的目标?
更新: 我想将一个包罗万象的虚拟主机指向一个目录并让 .htaccess 使用 mod_rewrite 动态选择路径,但(老实说)我已经筋疲力尽了。我会在早上再试一次,但与此同时,如果有人有好主意,我很想听听他们的意见!谢谢!