我在一个CentOS 7服务器上运行了一个vhost,它服务于两个预Prestashop商店。
在这个vhost conf文件中,我有一个ServerName和一个ServerAlias,分别指向一个专用的存储区。
最近,我把两个商店都移到了HTTPS,但还有一个问题:我知道如何重写URL,以便从HTTP重定向到HTTPS,但我可以根据客户机请求的URL重定向吗?
我知道如何在两个vhost上完成它,但是由于conf将接近相同,所以我只想用一个文件来完成它。
示例:将http://store1.example.com重写为https://store1.example.com,将http://store2.example.com重写为https://store2.example.com,它们都位于同一个Vhost conf文件中。
发布于 2018-03-01 20:15:07
您可以随意将它们放入一个或多个文件中,但最直接的方法是使用多个<VirtualHost>指令:
<VirtualHost *:80>
ServerName store1.example.com
Redirect permanent / https://store1.example.com
</VirtualHost>
<VirtualHost *:80>
ServerName store2.example.com
Redirect permanent / https://store2.example.com
</VirtualHost>
<VirtualHost *:443>
ServerName store1.example.com
ServerAlias store2.example.com
...
</VirtualHost>https://serverfault.com/questions/899547
复制相似问题