Switching two virtual host (configured with httpd.conf) using .htaccess
I have configured tow virtual host for two domains www.domain1.com and www.domain2.com:
<VirtualHost *>
ServerName prod.domain.com
ServerAlias www.domain1.com
DocumentRoot /data/prod/web/
DirectoryIndex index.php
<Directory "/data/pro开发者_开发知识库d/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /data/prod/lib/vendor/symfony/data/web/sf
<Directory "/data/prod/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</VirtualHost>
<VirtualHost *>
ServerName dev.domain.com
ServerAlias www.domain2.com
DocumentRoot /data/dev/web/
DirectoryIndex index.php
<Directory "/data/dev/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /data/dev/lib/vendor/symfony/data/web/sf
<Directory "/data/dev/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Now, I want with htaccess file to switch the folder pointing to the domain:
Before
/data/prod/web --> www.domain1.com
/data/dev/web --> www.domain2.com
After
/data/prod/web --> www.domain2.com
/data/dev/web --> www.domain1.com
Is it possible? could you help me ?
Thanks a lot
From the Apache documentation:
DocumentRoot Directive
Description: Directory that forms the main document tree visible from the web
Syntax: DocumentRoot directory-path
Default: DocumentRoot /usr/local/apache/htdocs
Context: server config, virtual host
Status: Core Module: core
Note what's in bold here...you cannot change the DocumentRoot from .htaccess files. Here is a list of all possible context values, FYI:
http://httpd.apache.org/docs/2.0/mod/directive-dict.html#Context
精彩评论