Apache-Ubuntu服务器-将HTTP重定向到HTTPS
我正在尝试将所有http重定向到https。 我已使用以下方法将Apache-Ubuntu服务器-将HTTP重定向到HTTPS,apache,.htaccess,redirect,ssl,Apache,.htaccess,Redirect,Ssl,我正在尝试将所有http重定向到https。 我已使用以下方法将.htaccess文件添加到我的根文件夹var/www/html/: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} </IfModule> 重新启动发动机 重写条件%{HTTPS}关闭 重写规则(*)https://
.htaccess
文件添加到我的根文件夹var/www/html/
:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
重新启动发动机
重写条件%{HTTPS}关闭
重写规则(*)https://%{HTTP\u HOST}%{REQUEST\u URI}
但是,此代码不起作用,页面仍显示http连接
我的网站使用https运行良好。如何将我的站点重定向到ssl连接?我必须重新启动apache吗?1)确保启用了
mod\u rewrite
(如果不启用,请重新启动服务器)。2) 检查是否允许htaccess文件(对于相关块,Apache配置文件->AllowOverride
设置为All
)。3) 确保/var/www/html/
是您的http
version1)模块重写的文档根文件夹已启用谢谢Justin,刚刚添加了选项-索引+FollowSymLinks AllowOverride All Require All approved
,如果我尝试打开http://example.com/phpmyadmin/
它不会重定向如果主机名匹配,则重写将是内部的,不带[R,L]
标志。也看到