从 http 重定向到 https 在 .htaccess 中不起作用

时间:2021-04-24 08:18:03

标签: http redirect https

我知道有几个相同的问题,我没有找到解决方案。 我有一个网站,我将此代码添加到 .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

而且它不会将 http 重定向到 https。当我手动输入带有 https 的网站时可以正常工作,但与 http 相同。第二个问题也差不多。如何在没有 www 的情况下从 http://www 和 https://www 重定向到 https://。是的,它正在重定向到 /public 文件夹,它必须在那里

0 个答案:

没有答案
相关问题