域名不redirect到HTTPS版本(Apache / Ubuntu)

第一次在这里发布。 我在这整个networking/服务器安装世界有点新,所以忍受我!

基本上,我有一个networking论坛,我一直在尝试实施HTTPS一段时间。 例如,如果我把https://example.com放在地址栏上,论坛的function就像一个魅力一样。

但是,我的问题是,如果我只是简单地把example.com放在地址栏上,它默认为http副本,是http://example.com

我已经阅读了许多关于如何做到这一点的指南,而且我已经为redirect添加了必要的.htaccess规则(我认为)。

 <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

这是我认为的重要部分,下面这些是由论坛软件自动生成的,我想。

 RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA] RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA] RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA] RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA] RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA] RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA] RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA] RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA] RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA] RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA] RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA] RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA] RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA] RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA] RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA] RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA] RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA] <IfModule mod_env.c> 

那么,有什么想法? 这是主机configuration的问题吗? 我感谢帮助。

将所有内容封装在<IfModule mod_rewrite.c>是在mod_rewrite模块未加载的情况下抑制错误。 所以你可以检查的第一件事是该模块是否被加载,因为如果它不是没有redirect将工作。 不过,在大多数Apache安装中,它将被加载。

另一个需要检查的问题是.htaccess文件是否在你的Apacheconfiguration中被启用,以及它们是否具有包含任意configuration的能力(比如你添加的规则)。 在您的Apacheconfiguration中查找AllowOverride语句。 它应该设置为All 。 您可能需要检查相关的<Directory>部分。

另一件要检查的事情是Apache的错误日志,有时候会发现configuration问题正在影响某些东西。