首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用ServerAlias重写Apache

用ServerAlias重写Apache
EN

Server Fault用户
提问于 2018-03-01 19:59:22
回答 1查看 3.1K关注 0票数 0

我在一个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文件中。

EN

回答 1

Server Fault用户

发布于 2018-03-01 20:15:07

您可以随意将它们放入一个或多个文件中,但最直接的方法是使用多个<VirtualHost>指令:

代码语言:javascript
复制
<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>
票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/899547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档