【问题标题】:Redirect to ssl site using htaccess [closed]使用 htaccess 重定向到 ssl 站点 [关闭]
【发布时间】:2013-11-20 11:51:22
【问题描述】:

我有一个域 example.com 并为 www.example.com 安装了 SSL。我想为以下规则创建一个 htaccess 文件:

Redirect all traffic from http://example.com to https://www.example.com
Redirect all traffic from http://www.example.com to https://www.example.com

【问题讨论】:

  • 您好,请始终记得先使用 Google。搜索Redirect to ssl site using htaccess 应该会为您提供所需的一切。谢谢!

标签: .htaccess redirect ssl


【解决方案1】:

您希望在文档根目录的 htaccess 文件中包含类似的内容,最好高于任何可能已经存在的规则。

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]

【讨论】:

  • 我得到:内部服务器错误
  • 我尝试了以下方法:Options +FollowSymLinks -MultiViews# Turn mod_rewrite onRewriteEngine OnRewriteBase /RewriteCond %{HTTPS} offRewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L],但它将http://domain重定向到https://domain而不是@987654333 >
  • @Gopu 你想要我的,我打错字了(拼写“rewrite”错了)
猜你喜欢
  • 2015-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-02
  • 2016-07-11
  • 1970-01-01
相关资源
最近更新 更多