【问题标题】:Redirect specific page on specific domain alias to https/SSL with .htaccess使用 .htaccess 将特定域别名上的特定页面重定向到 https/SSL
【发布时间】:2016-07-22 20:59:54
【问题描述】:

将特定域别名上的特定页面重定向到 https/SSL。

虚拟主机在同一个虚拟主机上设置了多个域别名。 它需要将特定域别名上的特定页面重定向到 https。

  • 域-a.com
  • 域-b.com
  • 域-c.com

http://www.domain-c.com/contact需要重定向到https://www.domain-c.com/contact

其他域 domain-a.com 和 domain-b.com 不需要重定向 /contact 到 https

【问题讨论】:

  • .htaccess 是首选方式

标签: .htaccess redirect url-rewriting


【解决方案1】:

根据您的设置,最有效的方法是使用网页代码。

在 php 中你可以使用下面的例子:

if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == ""){
 $redirect = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
 header("HTTP/1.1 301 Moved Permanently");
 header("Location: $redirect");
}

但其他选项也是可能的。例如对于 IIS,您可以在 web.config 中制定规则以匹配特定页面并将其重定向到 HTTPS。

.htaccess 中的基本重定向应该适合你。

redirect /contact https://www.domain-c.com/contact

有更漂亮的方法可以在 .htaccess 文件中执行此操作,但在发布之前没有测试环境。

【讨论】:

  • 了解更多信息会更容易为您提供帮助。
猜你喜欢
  • 2017-12-26
  • 1970-01-01
  • 2017-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-05
  • 2012-03-26
  • 1970-01-01
相关资源
最近更新 更多