Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache-Ubuntu服务器-将HTTP重定向到HTTPS_Apache_.htaccess_Redirect_Ssl - Fatal编程技术网

Apache-Ubuntu服务器-将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://

我正在尝试将所有http重定向到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]
标志。也看到