我有一个子域“staging.website.com”和“website.com”,我想使用相同的应用程序,但在不同的环境模式下“关闭”和“登台”。
我在 Apache 中设置了以下 vHost:
<VirtualHost 46.17.91.215:80>
ServerName staging.website.com
RackEnv staging
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/website/public_html/public
<Directory /home/website/public_html/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost 46.17.91.215:80>
ServerName website.com
ServerAlias www.website.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/website/public_html/public
RackEnv closed
<Directory /home/website/public_html/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
*显然我用“website.com”伪装了我的实际域。
无论RackEnv
虚拟主机中的设置如何,它们在访问时都使用相同的环境。我猜这是由于相同的文档根,但它必须是可以实现的。
我也试过了RailsEnv
。