我有 CentOs 7 和 Apache。我的网站有虚拟主机。一切正常。
但我想安装 lets encrypt 证书,安装很顺利,但是当我在 https 上加载网站时,它会将我重定向回 http,我真的不知道为什么。我没有在任何地方找到任何重定向规则或类似的东西。
这是我在 etc/httpd/sites-available 中的虚拟主机:
<VirtualHost *:80>
ServerName www.hodnoceniopvvv.cz
ServerAlias hodnoceniopvvv.cz
DocumentRoot /var/www/hodnoceniopvvv.cz/limesurvey
ErrorLog /var/www/hodnoceniopvvv.cz/error.log
CustomLog /var/www/hodnoceniopvvv.cz/requests.log combined
hodnoceniopvvv.cz-le-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.hodnoceniopvvv.cz
ServerAlias hodnoceniopvvv.cz
DocumentRoot /var/www/hodnoceniopvvv.cz/limesurvey
ErrorLog /var/www/hodnoceniopvvv.cz/error.log
CustomLog /var/www/hodnoceniopvvv.cz/requests.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/hodnoceniopvvv.cz/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hodnoceniopvvv.cz/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/hodnoceniopvvv.cz/chain.pem
</VirtualHost>
</IfModule>
当我尝试类似的事情时:
Redirect permanent / https://hodnoceniopvvv.cz/
浏览器在循环中写入它。
编辑//
在我的网站文件夹中找到了 .htaacces,也许这是导致问题的原因?但是当我删除它时,它仍然是同样的问题。
<IfModule mod_rewrite.c>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
# deny access to hidden files and directories except .well-known
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*/)?\.+ - [F]
</IfModule>
# deny access to hidden files and directories without mod_rewrite
RedirectMatch 403 ^/(?!\.well-known/)(.*/)?\.+
# General setting to properly handle LimeSurvey paths
# AcceptPathInfo on
任何人都可以帮助或告诉我应该在哪里寻找问题吗?
谢谢,
最好的问候
最佳答案
如果你正在写作
Redirect permanent / https://hodnoceniopvvv.cz
在 ssl 配置文件中也会导致循环。您只需要在创建端口 80 的虚拟主机的文件中重定向它,即第一个配置文件。
否则
我建议您在端口 80 和 443 上为虚拟主机创建两个不同的文件,并将来自 apache2.conf 的请求重定向到这些文件。流程会更清晰,更容易进一步调试
关于linux - Apache 将 HTTPS 重定向到 HTTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56774608/