安装 ssl 证书后重定向错误太多
Too many redirects error after installing ssl certificate
安装 ssl 证书后,我的网站无法正常工作。我是 运行 我在 vps 上的 cakephp 1.3 站点,它在没有 https 的情况下工作得很好,但是当我通过太多重定向错误启用 https 时,当我查看调试工具时,我看到来自 http (301) 的重定向循环-> https (302) -> http -> https
我在所有位置的 .htaccess 文件中添加了 mode_rewrite 规则
root -> .htaccess, app./.htaccess, app/webroot.htaccess
我也对代码做了一些调整,但我发现当我启用 https 时它永远不会访问代码。现在我没有使用 .htacess,而是直接将我的虚拟主机指向 webroot 文件夹,但仍然出现重定向循环
我也检查了我的 dns 高级设置,没有发现问题。
重定向图像 link:
https://gitlab.com/CPW2DO/newsite/uploads/a85856bcea45f463aa906916cf0025be/too_many_redirects_http.png
DNS 设置 Link:
https://gitlab.com/CPW2DO/newsite/uploads/280ba2d0cbc8b2584726a26a94e76a4b/dns_settings.jpg
非常感谢任何帮助提前致谢。
这是我的虚拟主机配置方式。
<VirtualHost *:80>
DocumentRoot "/var/www/html/opa/staging/current/app/webroot"
<Directory /var/www/html/opa/staging/current/app/webroot>
Options Indexes FollowSymLinks MultiViews
# AllowOverride All
# Require all granted
AllowOverride None
Order deny,allow
Allow from all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
ServerName opa-staging.capwell.nl
ServerAlias www.opa-staging.capwell.nl
Redirect permanent / https://opa-staging.capwell.nl/
ErrorLog ${APACHE_LOG_DIR}/opa-staging-error.log
CustomLog ${APACHE_LOG_DIR}/opa-staging-access.log combined
</VirtualHost>
<virtualhost *:443>
DocumentRoot "/var/www/html/opa/staging/current/app/webroot"
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/certificate.crt
SSLCertificateKeyFile /etc/apache2/ssl/certificate.key
SSLCertificateChainFile /etc/apache2/ssl/cabundle.crt
</virtualhost>
在关注@Greg Schmidt 评论后,我将我的 http 配置添加到 https 块并且它有效(耶)
<VirtualHost *:80>
DocumentRoot "/var/www/html/opa/staging/current/app/webroot"
<Directory /var/www/html/opa/staging/current/app/webroot>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
ServerName opa-staging.capwell.nl
ServerAlias www.opa-staging.capwell.nl
Redirect permanent / https://opa-staging.capwell.nl/
ErrorLog ${APACHE_LOG_DIR}/opa-staging-error.log
CustomLog ${APACHE_LOG_DIR}/opa-staging-access.log combined
</VirtualHost>
<virtualhost *:443>
DocumentRoot "/var/www/html/opa/staging/current/app/webroot"
<Directory /var/www/html/opa/staging/current/app/webroot>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
ServerName opa-staging.capwell.nl
ServerAlias www.opa-staging.capwell.n
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/certificate.crt
SSLCertificateKeyFile /etc/apache2/ssl/certificate.key
SSLCertificateChainFile /etc/apache2/ssl/cabundle.crt
</virtualhost>
安装 ssl 证书后,我的网站无法正常工作。我是 运行 我在 vps 上的 cakephp 1.3 站点,它在没有 https 的情况下工作得很好,但是当我通过太多重定向错误启用 https 时,当我查看调试工具时,我看到来自 http (301) 的重定向循环-> https (302) -> http -> https
我在所有位置的 .htaccess 文件中添加了 mode_rewrite 规则
root -> .htaccess, app./.htaccess, app/webroot.htaccess 我也对代码做了一些调整,但我发现当我启用 https 时它永远不会访问代码。现在我没有使用 .htacess,而是直接将我的虚拟主机指向 webroot 文件夹,但仍然出现重定向循环
我也检查了我的 dns 高级设置,没有发现问题。
重定向图像 link: https://gitlab.com/CPW2DO/newsite/uploads/a85856bcea45f463aa906916cf0025be/too_many_redirects_http.png
DNS 设置 Link:
https://gitlab.com/CPW2DO/newsite/uploads/280ba2d0cbc8b2584726a26a94e76a4b/dns_settings.jpg
非常感谢任何帮助提前致谢。
这是我的虚拟主机配置方式。
<VirtualHost *:80>
DocumentRoot "/var/www/html/opa/staging/current/app/webroot"
<Directory /var/www/html/opa/staging/current/app/webroot>
Options Indexes FollowSymLinks MultiViews
# AllowOverride All
# Require all granted
AllowOverride None
Order deny,allow
Allow from all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
ServerName opa-staging.capwell.nl
ServerAlias www.opa-staging.capwell.nl
Redirect permanent / https://opa-staging.capwell.nl/
ErrorLog ${APACHE_LOG_DIR}/opa-staging-error.log
CustomLog ${APACHE_LOG_DIR}/opa-staging-access.log combined
</VirtualHost>
<virtualhost *:443>
DocumentRoot "/var/www/html/opa/staging/current/app/webroot"
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/certificate.crt
SSLCertificateKeyFile /etc/apache2/ssl/certificate.key
SSLCertificateChainFile /etc/apache2/ssl/cabundle.crt
</virtualhost>
在关注@Greg Schmidt 评论后,我将我的 http 配置添加到 https 块并且它有效(耶)
<VirtualHost *:80>
DocumentRoot "/var/www/html/opa/staging/current/app/webroot"
<Directory /var/www/html/opa/staging/current/app/webroot>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
ServerName opa-staging.capwell.nl
ServerAlias www.opa-staging.capwell.nl
Redirect permanent / https://opa-staging.capwell.nl/
ErrorLog ${APACHE_LOG_DIR}/opa-staging-error.log
CustomLog ${APACHE_LOG_DIR}/opa-staging-access.log combined
</VirtualHost>
<virtualhost *:443>
DocumentRoot "/var/www/html/opa/staging/current/app/webroot"
<Directory /var/www/html/opa/staging/current/app/webroot>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
ServerName opa-staging.capwell.nl
ServerAlias www.opa-staging.capwell.n
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/certificate.crt
SSLCertificateKeyFile /etc/apache2/ssl/certificate.key
SSLCertificateChainFile /etc/apache2/ssl/cabundle.crt
</virtualhost>