apache2 vhost redirection
I have defined differents hosts in my windows host file, one for every project release (rc1, rc2 etc..) I would like to create one vhost per release so I can redirect directly to its subdir, for example :
pp15.mv => http://localhost/mv/pp15/.....
pp16.mv => http://localhost/mv/pp16/.....moreover, I need to redirect the host ppX.mv to an autologin url, something looks like /mv_dbname.php?login=testlogin&mdp=202cb962ac59075b964b07152d234b70
so, finally, I want to type this in my urlbar :
http://pp15.mv and get redirected to http://pp15.mv/mv_dbname.php?login=testlogin&mdp=202cb962ac59075b964b07152d234b70In my virtual host file I have something like this :
<VirtualHost *:80>
ServerName pp15.mv
DocumentRoot "D:\apache\htdocs\mv\pp15"
<Directory "D:\apache\htdocs\mv\pp15">
AllowOverride All
Allow from All
</Directory>
RewriteEn开发者_JAVA技巧gine On
RewriteRule ^/index.php /myvisitv3_dbname.php?login=johsmi&mdp=202cb962ac59075b964b07152d234b70 [R]
RewriteRule ^(/)?$ /myvisitv3_dbname.php?login=johsmi&mdp=202cb962ac59075b964b07152d234b70 [R]
</VirtualHost>
The first redirection works great, but if i try to redirect directly the host, I get a redirection error (too many redirections occured)
Do someone have an idea ?
Thank you previously.
ok, finally here what I did :
<VirtualHost *:80>
ServerName pp16.mv
RewriteEngine on
RewriteCond %{HTTP_HOST} ^pp16\.mv$
RewriteRule ^(/)?$ /mv/pp16/xxx/xxx_dbname.php?login=johsmi&mdp=202cb962ac59075b964b07152d234b70 [R]
</VirtualHost>
no [L] on redirection because app have internal redirection, and no document root because php won't be able to read $_SERVER['REQUESTED_URI'] var correctly, so I could have did this (I prefer)
<VirtualHost *:80>
ServerName pp16.mv
DocumentRoot "D:\apache\htdocs\mv\pp16\xxx"
RewriteEngine on
RewriteCond %{HTTP_HOST} ^pp16\.mv$
RewriteRule ^(/)?$ /xxx_dbname.php?login=johsmi&mdp=202cb962ac59075b964b07152d234b70 [R]
</VirtualHost>
but php would have misread the app path (/ instead of /mv/pp16/xxx/)
精彩评论