这就是我想要实现的目标:
请注意: 它是一个共享实例 - 所以已经配置了另一个应用程序。
我当前的解决方案配置:
# VirtualHost Listening on Port 80
123.123.1.1:80
# Original Configuration for Existing Application
<VirtualHost *>
ServerName 123.123.1.1:80
# Additional cluster configuration using Proxy ( mod_proxy ) & LoadBalancer
</VirtualHost>
<VirtualHost *>
ServerName domain1.com
Redirect / https://domain1.com/app1/$1
</VirtualHost>
<VirtualHost *>
ServerName domain2.com
Redirect / https://domain2.com/app2/$1
</VirtualHost>
我尝试过的替代方案是:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://domain1.com/app1/$1
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://domain2.com/app2/$1
有人可以指出我应该做哪些其他配置? 我的错误是什么?
答案 0 :(得分:0)
尝试使用条件查找域,然后根据请求的传入域重定向。
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com [NC]
RewriteRule (.*)$ https://domain1.com/app1/$1/ [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com [NC]
RewriteRule (.*)$ https://domain2.com/app2/$1/ [R=301,L]